MCPcopy
hub / github.com/plotly/dash / write_help_file

Function write_help_file

dash/development/_r_components_generation.py:366–454  ·  view source on GitHub ↗

Write R documentation file (.Rd) given component name and properties. Parameters ---------- name = the name of the Dash component for which a help file is generated props = the properties of the component description = the component's description, inserted into help file header

(name, props, description, prefix, rpkg_data)

Source from the content-addressed store, hash-verified

364
365
366def write_help_file(name, props, description, prefix, rpkg_data):
367 """Write R documentation file (.Rd) given component name and properties.
368
369 Parameters
370 ----------
371 name = the name of the Dash component for which a help file is generated
372 props = the properties of the component
373 description = the component's description, inserted into help file header
374 prefix = the DashR library prefix (optional, can be a blank string)
375 rpkg_data = package metadata (optional)
376
377 Returns
378 -------
379 writes an R help file to the man directory for the generated R package
380 """
381 funcname = format_fn_name(prefix, name)
382 file_name = funcname + ".Rd"
383
384 wildcards = ""
385 default_argtext = ""
386 item_text = ""
387 accepted_wildcards = ""
388
389 # the return value of all Dash components should be the same,
390 # in an abstract sense -- they produce a list
391 value_text = "named list of JSON elements corresponding to React.js properties and their values" # noqa:E501
392
393 prop_keys = list(props.keys())
394
395 if any(key.endswith("-*") for key in prop_keys):
396 accepted_wildcards = get_wildcards_r(prop_keys)
397 wildcards = ", ..."
398
399 # Filter props to remove those we don't want to expose
400 for item in prop_keys[:]:
401 if item.endswith("-*") or item in r_keywords or item == "setProps":
402 prop_keys.remove(item)
403
404 default_argtext += ", ".join("{}=NULL".format(p) for p in prop_keys)
405
406 item_text += "\n\n".join(
407 "\\item{{{}}}{{{}{}}}".format(
408 p, print_r_type(props[p]["type"]), props[p]["description"]
409 )
410 for p in prop_keys
411 )
412
413 # auto-replace any unescaped backslashes for compatibility with R docs
414 description = re.sub(r"(?<!\\)%", "\\%", description)
415 item_text = re.sub(r"(?<!\\)%", "\\%", item_text)
416
417 # scrub examples which begin with **Example Usage**, as these should be
418 # provided as R code within dash-info.yaml
419 if "**Example Usage**" in description:
420 description = description.split("**Example Usage**")[0].rstrip()
421
422 if wildcards == ", ...":
423 default_argtext += wildcards

Callers 1

write_class_fileFunction · 0.85

Calls 10

get_wildcards_rFunction · 0.85
print_r_typeFunction · 0.85
keysMethod · 0.80
subMethod · 0.80
format_fn_nameFunction · 0.70
wrapFunction · 0.70
removeMethod · 0.45
formatMethod · 0.45
fillMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…