MCPcopy Index your code
hub / github.com/plotly/dash / create_prop_docstring

Function create_prop_docstring

dash/development/_py_components_generation.py:548–645  ·  view source on GitHub ↗

Create the Dash component prop docstring. Parameters ---------- prop_name: str Name of the Dash component prop type_object: dict react-docgen-generated prop type dictionary required: bool Component is required? description: str Dash component d

(
    prop_name,
    type_object,
    required,
    description,
    default,
    indent_num,
    is_flow_type=False,
)

Source from the content-addressed store, hash-verified

546# pylint: disable=too-many-arguments
547# pylint: disable=too-many-locals
548def create_prop_docstring(
549 prop_name,
550 type_object,
551 required,
552 description,
553 default,
554 indent_num,
555 is_flow_type=False,
556):
557 """Create the Dash component prop docstring.
558 Parameters
559 ----------
560 prop_name: str
561 Name of the Dash component prop
562 type_object: dict
563 react-docgen-generated prop type dictionary
564 required: bool
565 Component is required?
566 description: str
567 Dash component description
568 default: dict
569 Either None if a default value is not defined, or
570 dict containing the key 'value' that defines a
571 default value for the prop
572 indent_num: int
573 Number of indents to use for the context block
574 (creates 2 spaces for every indent)
575 is_flow_type: bool
576 Does the prop use Flow types? Otherwise, uses PropTypes
577 Returns
578 -------
579 str
580 Dash component prop docstring
581 """
582 py_type_name = js_to_py_type(
583 type_object=type_object, is_flow_type=is_flow_type, indent_num=indent_num
584 )
585 indent_spacing = " " * indent_num
586
587 default = default["value"] if default else ""
588 default = fix_keywords(default)
589
590 is_required = "optional"
591 if required:
592 is_required = "required"
593 elif default and default not in ["None", "{}", "[]"]:
594 is_required = "default " + default.replace("\n", "")
595
596 # formats description
597 period = "." if description else ""
598 description = description.strip().strip(".").replace('"', r"\"") + period
599 desc_indent = indent_spacing + " "
600 description = fill(
601 description,
602 initial_indent=desc_indent,
603 subsequent_indent=desc_indent,
604 break_long_words=False,
605 break_on_hyphens=False,

Callers 3

create_docstringFunction · 0.85
shape_or_exactFunction · 0.85

Calls 3

js_to_py_typeFunction · 0.85
fix_keywordsFunction · 0.85
findMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…