Skip to content

Commit

Permalink
Merge pull request #638 from plotly/0.39.0-issue591
Browse files Browse the repository at this point in the history
Fix documentation bug which omits children from R help pages
  • Loading branch information
rpkyle authored Mar 25, 2019
2 parents 6cee22c + a779c60 commit 0812b1a
Showing 1 changed file with 22 additions and 27 deletions.
49 changes: 22 additions & 27 deletions dash/development/_r_components_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@

frame_element_template = '''`{dep_name}` = structure(list(name = "{dep_name}",
version = "{project_ver}", src = list(href = NULL,
file = "deps/"), meta = NULL,
file = "deps"), meta = NULL,
script = "{dep_rpp}",
stylesheet = NULL, head = NULL, attachment = NULL, package = "{rpkgname}",
all_files = FALSE), class = "html_dependency")'''

frame_body_template = '''`{project_shortname}` = structure(list(name = "{project_shortname}",
version = "{project_ver}", src = list(href = NULL,
file = "deps/"), meta = NULL,
file = "deps"), meta = NULL,
script = "{dep_rpp}",
stylesheet = NULL, head = NULL, attachment = NULL, package = "{rpkgname}",
all_files = FALSE), class = "html_dependency")''' # noqa:E501
Expand All @@ -65,7 +65,7 @@
}}
\\usage{{
{prefix}{name}({default_argtext}, ...)
{prefix}{name}({default_argtext})
}}
\\arguments{{
Expand All @@ -78,7 +78,8 @@
Version: {package_version}
Authors @R: as.person(c({package_author}))
Description: {package_description}
Depends: R (>= 3.5.0)
Depends: R (>= 3.0.2)
Imports: dashR
Suggests: testthat, roxygen2
License: {package_license}
URL: {package_url}
Expand Down Expand Up @@ -223,8 +224,7 @@ def generate_class_string(name, props, project_shortname, prefix):
def generate_js_metadata(pkg_data, project_shortname):
"""
Dynamically generate R function to supply JavaScript
dependency information required by htmltools package,
which is loaded by dashR.
and CSS dependency information required by dashR package.
Parameters
----------
Expand Down Expand Up @@ -305,9 +305,6 @@ def write_help_file(name, props, description, prefix):
default_argtext = ''
item_text = ''

# Ensure props are ordered with children first
props = reorder_props(props=props)

prop_keys = list(props.keys())

has_wildcards = any('-*' in key for key in prop_keys)
Expand All @@ -331,6 +328,7 @@ def write_help_file(name, props, description, prefix):

if has_wildcards:
item_text += '\n\n\\item{...}{wildcards: `data-*` or `aria-*`}'
default_argtext += ', ...'

file_path = os.path.join('man', file_name)
with open(file_path, 'w') as f:
Expand All @@ -350,6 +348,18 @@ def write_class_file(name,
prefix=None):
props = reorder_props(props=props)

# generate the R help pages for each of the Dash components that we
# are transpiling -- this is done to avoid using Roxygen2 syntax,
# we may eventually be able to generate similar documentation using
# doxygen and an R plugin, but for now we'll just do it on our own
# from within Python
write_help_file(
name,
props,
description,
prefix
)

import_string =\
"# AUTO GENERATED FILE - DO NOT EDIT\n\n"
class_string = generate_class_string(
Expand All @@ -365,26 +375,13 @@ def write_class_file(name,
f.write(import_string)
f.write(class_string)

# generate the R help pages for each of the Dash components that we
# are transpiling -- this is done to avoid using Roxygen2 syntax,
# we may eventually be able to generate similar documentation using
# doxygen and an R plugin, but for now we'll just do it on our own
# from within Python
write_help_file(
name,
props,
description,
prefix
)

print('Generated {}'.format(file_name))


def write_js_metadata(pkg_data, project_shortname):
"""
Write an internal (not exported) R function to return all JS
dependencies as required by htmltools package given a
function string
dependencies as required by dashR.
Parameters
----------
Expand Down Expand Up @@ -488,10 +485,8 @@ def generate_rpkg(pkg_data,
pkghelp_stub_path = os.path.join('man', package_name + '-package.Rd')

# generate the internal (not exported to the user) functions which
# supply the JavaScript dependencies to the htmltools package,
# which is required by DashR (this avoids having to generate an
# RData file from within Python, given the current package generation
# workflow)
# supply the JavaScript dependencies to the dashR package.
# this avoids having to generate an RData file from within Python.
write_js_metadata(
pkg_data=pkg_data,
project_shortname=project_shortname
Expand Down

0 comments on commit 0812b1a

Please sign in to comment.