Skip to content

Commit 05a5a54

Browse files
updated tests for new docstring format
1 parent 2e42340 commit 05a5a54

File tree

7 files changed

+271
-160
lines changed

7 files changed

+271
-160
lines changed

dash/development/_py_components_generation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ def create_prop_docstring(
439439

440440
# format and rewrite the intro to the nested dicts
441441
intro1, intro2, dict_descr = py_type_name.partition("with keys:")
442-
intro = "".join([f"`{prop_name}`", " is a ", intro1, intro2])
442+
intro = "".join(["`{}`".format(prop_name), " is a ", intro1, intro2])
443443
intro = fill(
444444
intro,
445445
initial_indent=desc_indent,
@@ -531,7 +531,7 @@ def shape_or_exact():
531531
"list"
532532
+ (
533533
" of {}".format(
534-
js_to_py_type(type_object["value"])
534+
js_to_py_type(type_object["value"]) + "s"
535535
if js_to_py_type(type_object["value"]).split(" ")[0] != "dict"
536536
else js_to_py_type(type_object["value"]).replace("dict", "dicts", 1)
537537
)
@@ -590,7 +590,7 @@ def map_js_to_py_types_flow_types(type_object):
590590
required=prop["value"]["required"],
591591
description=prop["value"].get("description", ""),
592592
default=prop.get("defaultValue"),
593-
indent_num=indent_num,
593+
indent_num=indent_num + 2,
594594
is_flow_type=True,
595595
)
596596
for prop in type_object["signature"]["properties"]

tests/unit/development/__init__.py

Lines changed: 71 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -13,51 +13,81 @@ def has_trailing_space(s):
1313
"It's multiple lines long.",
1414
"",
1515
"Keyword arguments:",
16+
"",
1617
"- children (a list of or a singular dash component, string or number; optional)",
17-
"- optionalArray (list; optional): Description of optionalArray",
18+
"",
19+
"- id (string; optional)",
20+
"",
21+
"- aria-* (string; optional)",
22+
"",
23+
"- customArrayProp (list; optional)",
24+
"",
25+
"- customProp (optional)",
26+
"",
27+
"- data-* (string; optional)",
28+
"",
29+
"- in (string; optional)",
30+
"",
31+
"- optionalAny (boolean | number | string | dict | list; optional)",
32+
"",
33+
"- optionalArray (list; optional):",
34+
" Description of optionalArray. ",
35+
"",
36+
"- optionalArrayOf (list of numbers; optional)",
37+
"",
1838
"- optionalBool (boolean; optional)",
39+
"",
40+
"- optionalElement (dash component; optional)",
41+
"",
42+
"- optionalEnum (a value equal to: 'News'," " 'Photos'; optional)",
43+
"",
44+
"- optionalNode (a list of or a singular dash component, string or number; optional)",
45+
"",
1946
"- optionalNumber (number; default 42)",
47+
"",
2048
"- optionalObject (dict; optional)",
49+
"",
50+
"- optionalObjectOf (dict with strings as keys and values of type number; optional)",
51+
"",
52+
"- optionalObjectWithExactAndNestedDescription (dict; optional) ",
53+
"",
54+
" `optionalObjectWithExactAndNestedDescription` is a dict with keys: ",
55+
"",
56+
" - color (string; optional) ",
57+
"",
58+
" - figure (dict; optional):",
59+
" Figure is a plotly graph object. ",
60+
"",
61+
" `figure` is a dict with keys: ",
62+
"",
63+
" - data (list of dicts; optional):",
64+
" data is a collection of traces. ",
65+
"",
66+
" - layout (dict; optional):",
67+
" layout describes the rest of the figure. ",
68+
"",
69+
" - fontSize (number; optional)",
70+
"",
71+
"- optionalObjectWithShapeAndNestedDescription (dict; optional) ",
72+
"",
73+
" `optionalObjectWithShapeAndNestedDescription` is a dict with keys: ",
74+
"",
75+
" - color (string; optional) ",
76+
"",
77+
" - figure (dict; optional):",
78+
" Figure is a plotly graph object. ",
79+
"",
80+
" `figure` is a dict with keys: ",
81+
"",
82+
" - data (list of dicts; optional):",
83+
" data is a collection of traces. ",
84+
"",
85+
" - layout (dict; optional):",
86+
" layout describes the rest of the figure. ",
87+
"",
88+
" - fontSize (number; optional)",
89+
"",
2190
"- optionalString (string; default 'hello world')",
22-
"- optionalNode (a list of or a singular dash component, "
23-
"string or number; optional)",
24-
"- optionalElement (dash component; optional)",
25-
"- optionalEnum (a value equal to: 'News', 'Photos'; optional)",
91+
"",
2692
"- optionalUnion (string | number; optional)",
27-
"- optionalArrayOf (list of numbers; optional)",
28-
"- optionalObjectOf (dict with strings as keys and values "
29-
"of type number; optional)",
30-
"- optionalObjectWithExactAndNestedDescription (dict; optional): "
31-
"optionalObjectWithExactAndNestedDescription has the "
32-
"following type: dict containing keys "
33-
"'color', 'fontSize', 'figure'.",
34-
"Those keys have the following types:",
35-
" - color (string; optional)",
36-
" - fontSize (number; optional)",
37-
" - figure (dict; optional): Figure is a plotly graph object. "
38-
"figure has the following type: dict containing "
39-
"keys 'data', 'layout'.",
40-
"Those keys have the following types:",
41-
" - data (list of dicts; optional): data is a collection of traces",
42-
" - layout (dict; optional): layout describes " "the rest of the figure",
43-
"- optionalObjectWithShapeAndNestedDescription (dict; optional): "
44-
"optionalObjectWithShapeAndNestedDescription has the "
45-
"following type: dict containing keys "
46-
"'color', 'fontSize', 'figure'.",
47-
"Those keys have the following types:",
48-
" - color (string; optional)",
49-
" - fontSize (number; optional)",
50-
" - figure (dict; optional): Figure is a plotly graph object. "
51-
"figure has the following type: dict containing "
52-
"keys 'data', 'layout'.",
53-
"Those keys have the following types:",
54-
" - data (list of dicts; optional): data is a collection of traces",
55-
" - layout (dict; optional): layout describes " "the rest of the figure",
56-
"- optionalAny (boolean | number | string | dict | " "list; optional)",
57-
"- customProp (optional)",
58-
"- customArrayProp (list; optional)",
59-
"- data-* (string; optional)",
60-
"- aria-* (string; optional)",
61-
"- in (string; optional)",
62-
"- id (string; optional)",
6393
]

tests/unit/development/metadata_test.py

Lines changed: 75 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,57 +9,97 @@ class Table(Component):
99
It's multiple lines long.
1010
1111
Keyword arguments:
12+
1213
- children (a list of or a singular dash component, string or number; optional)
13-
- optionalArray (list; optional): Description of optionalArray
14+
15+
- id (string; optional)
16+
17+
- aria-* (string; optional)
18+
19+
- customArrayProp (list; optional)
20+
21+
- customProp (optional)
22+
23+
- data-* (string; optional)
24+
25+
- in (string; optional)
26+
27+
- optionalAny (boolean | number | string | dict | list; optional)
28+
29+
- optionalArray (list; optional):
30+
Description of optionalArray.
31+
32+
- optionalArrayOf (list of numbers; optional)
33+
1434
- optionalBool (boolean; optional)
15-
- optionalNumber (number; default 42)
16-
- optionalObject (dict; optional)
17-
- optionalString (string; default 'hello world')
18-
- optionalNode (a list of or a singular dash component, string or number; optional)
35+
1936
- optionalElement (dash component; optional)
37+
2038
- optionalEnum (a value equal to: 'News', 'Photos'; optional)
21-
- optionalUnion (string | number; optional)
22-
- optionalArrayOf (list of numbers; optional)
39+
40+
- optionalNode (a list of or a singular dash component, string or number; optional)
41+
42+
- optionalNumber (number; default 42)
43+
44+
- optionalObject (dict; optional)
45+
2346
- optionalObjectOf (dict with strings as keys and values of type number; optional)
24-
- optionalObjectWithExactAndNestedDescription (dict; optional): optionalObjectWithExactAndNestedDescription has the following type: dict containing keys 'color', 'fontSize', 'figure'.
25-
Those keys have the following types:
26-
- color (string; optional)
27-
- fontSize (number; optional)
28-
- figure (dict; optional): Figure is a plotly graph object. figure has the following type: dict containing keys 'data', 'layout'.
29-
Those keys have the following types:
30-
- data (list of dicts; optional): data is a collection of traces
31-
- layout (dict; optional): layout describes the rest of the figure
32-
- optionalObjectWithShapeAndNestedDescription (dict; optional): optionalObjectWithShapeAndNestedDescription has the following type: dict containing keys 'color', 'fontSize', 'figure'.
33-
Those keys have the following types:
34-
- color (string; optional)
35-
- fontSize (number; optional)
36-
- figure (dict; optional): Figure is a plotly graph object. figure has the following type: dict containing keys 'data', 'layout'.
37-
Those keys have the following types:
38-
- data (list of dicts; optional): data is a collection of traces
39-
- layout (dict; optional): layout describes the rest of the figure
40-
- optionalAny (boolean | number | string | dict | list; optional)
41-
- customProp (optional)
42-
- customArrayProp (list; optional)
43-
- data-* (string; optional)
44-
- aria-* (string; optional)
45-
- in (string; optional)
46-
- id (string; optional)"""
47+
48+
- optionalObjectWithExactAndNestedDescription (dict; optional)
49+
50+
`optionalObjectWithExactAndNestedDescription` is a dict with keys:
51+
52+
- color (string; optional)
53+
54+
- figure (dict; optional):
55+
Figure is a plotly graph object.
56+
57+
`figure` is a dict with keys:
58+
59+
- data (list of dicts; optional):
60+
data is a collection of traces.
61+
62+
- layout (dict; optional):
63+
layout describes the rest of the figure.
64+
65+
- fontSize (number; optional)
66+
67+
- optionalObjectWithShapeAndNestedDescription (dict; optional)
68+
69+
`optionalObjectWithShapeAndNestedDescription` is a dict with keys:
70+
71+
- color (string; optional)
72+
73+
- figure (dict; optional):
74+
Figure is a plotly graph object.
75+
76+
`figure` is a dict with keys:
77+
78+
- data (list of dicts; optional):
79+
data is a collection of traces.
80+
81+
- layout (dict; optional):
82+
layout describes the rest of the figure.
83+
84+
- fontSize (number; optional)
85+
86+
- optionalString (string; default 'hello world')
87+
88+
- optionalUnion (string | number; optional)"""
4789
@_explicitize_args
4890
def __init__(self, children=None, optionalArray=Component.UNDEFINED, optionalBool=Component.UNDEFINED, optionalFunc=Component.UNDEFINED, optionalNumber=Component.UNDEFINED, optionalObject=Component.UNDEFINED, optionalString=Component.UNDEFINED, optionalSymbol=Component.UNDEFINED, optionalNode=Component.UNDEFINED, optionalElement=Component.UNDEFINED, optionalMessage=Component.UNDEFINED, optionalEnum=Component.UNDEFINED, optionalUnion=Component.UNDEFINED, optionalArrayOf=Component.UNDEFINED, optionalObjectOf=Component.UNDEFINED, optionalObjectWithExactAndNestedDescription=Component.UNDEFINED, optionalObjectWithShapeAndNestedDescription=Component.UNDEFINED, optionalAny=Component.UNDEFINED, customProp=Component.UNDEFINED, customArrayProp=Component.UNDEFINED, id=Component.UNDEFINED, **kwargs):
49-
self._prop_names = ['children', 'optionalArray', 'optionalBool', 'optionalNumber', 'optionalObject', 'optionalString', 'optionalNode', 'optionalElement', 'optionalEnum', 'optionalUnion', 'optionalArrayOf', 'optionalObjectOf', 'optionalObjectWithExactAndNestedDescription', 'optionalObjectWithShapeAndNestedDescription', 'optionalAny', 'customProp', 'customArrayProp', 'data-*', 'aria-*', 'in', 'id']
91+
self._prop_names = ['children', 'id', 'aria-*', 'customArrayProp', 'customProp', 'data-*', 'in', 'optionalAny', 'optionalArray', 'optionalArrayOf', 'optionalBool', 'optionalElement', 'optionalEnum', 'optionalNode', 'optionalNumber', 'optionalObject', 'optionalObjectOf', 'optionalObjectWithExactAndNestedDescription', 'optionalObjectWithShapeAndNestedDescription', 'optionalString', 'optionalUnion']
5092
self._type = 'Table'
5193
self._namespace = 'TableComponents'
5294
self._valid_wildcard_attributes = ['data-', 'aria-']
53-
self.available_properties = ['children', 'optionalArray', 'optionalBool', 'optionalNumber', 'optionalObject', 'optionalString', 'optionalNode', 'optionalElement', 'optionalEnum', 'optionalUnion', 'optionalArrayOf', 'optionalObjectOf', 'optionalObjectWithExactAndNestedDescription', 'optionalObjectWithShapeAndNestedDescription', 'optionalAny', 'customProp', 'customArrayProp', 'data-*', 'aria-*', 'in', 'id']
95+
self.available_properties = ['children', 'id', 'aria-*', 'customArrayProp', 'customProp', 'data-*', 'in', 'optionalAny', 'optionalArray', 'optionalArrayOf', 'optionalBool', 'optionalElement', 'optionalEnum', 'optionalNode', 'optionalNumber', 'optionalObject', 'optionalObjectOf', 'optionalObjectWithExactAndNestedDescription', 'optionalObjectWithShapeAndNestedDescription', 'optionalString', 'optionalUnion']
5496
self.available_wildcard_properties = ['data-', 'aria-']
55-
5697
_explicit_args = kwargs.pop('_explicit_args')
5798
_locals = locals()
5899
_locals.update(kwargs) # For wildcard attrs
59100
args = {k: _locals[k] for k in _explicit_args if k != 'children'}
60-
61101
for k in []:
62102
if k not in args:
63103
raise TypeError(
64104
'Required argument `' + k + '` was not specified.')
65-
super(Table, self).__init__(children=children, **args)
105+
super(Table, self).__init__(children=children, **args)

0 commit comments

Comments
 (0)