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,
)
| 546 | # pylint: disable=too-many-arguments |
| 547 | # pylint: disable=too-many-locals |
| 548 | def 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, |
no test coverage detected
searching dependent graphs…