Skip to content

Commit

Permalink
Libdoc: Don't write custom types to legacy dataTypes in specs.
Browse files Browse the repository at this point in the history
`dataTypes` is deprecated and now restored to same structure and
content as in RF 4.x. All new additions, including custom types
(#4088), are only available under `types`. For some details see #4160.
  • Loading branch information
pekkaklarck committed Feb 6, 2022
1 parent b242f79 commit 3a8687a
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 41 deletions.
42 changes: 29 additions & 13 deletions atest/robot/libdoc/datatypes_py-json.robot
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,18 @@ Keyword Arguments
${MODEL}[keywords][4][args] list_of_str: List[str] dict_str_int: Dict[str, int] Whatever: Any *args: List[typing.Any]

TypedDict
${Model}[dataTypes][typedDicts][0][type] TypedDict
${Model}[dataTypes][typedDicts][0][name] GeoLocation
${Model}[dataTypes][typedDicts][0][doc] <p>Defines the geolocation.</p>
${MODEL}[dataTypes][typedDicts][0][type] TypedDict
${MODEL}[dataTypes][typedDicts][0][name] GeoLocation
${MODEL}[dataTypes][typedDicts][0][doc] <p>Defines the geolocation.</p>
... <ul>
... <li><code>latitude</code> Latitude between -90 and 90.</li>
... <li><code>longitude</code> Longitude between -180 and 180.</li>
... <li><code>accuracy</code> <b>Optional</b> Non-negative accuracy value. Defaults to 0.</li>
... </ul>
... <p>Example usage: <code>{'latitude': 59.95, 'longitude': 30.31667}</code></p>
${MODEL}[types][3][type] TypedDict
${MODEL}[types][3][name] GeoLocation
${MODEL}[types][3][doc] <p>Defines the geolocation.</p>
... <ul>
... <li><code>latitude</code> Latitude between -90 and 90.</li>
... <li><code>longitude</code> Longitude between -180 and 180.</li>
Expand Down Expand Up @@ -59,25 +68,32 @@ TypedDict Items
END

Enum
${Model}[dataTypes][enums][0][type] Enum
${Model}[dataTypes][enums][0][name] AssertionOperator
${Model}[dataTypes][enums][0][doc] <p>This is some Doc</p>
${MODEL}[dataTypes][enums][0][type] Enum
${MODEL}[dataTypes][enums][0][name] AssertionOperator
${MODEL}[dataTypes][enums][0][doc] <p>This is some Doc</p>
... <p>This has was defined by assigning to __doc__.</p>
${MODEL}[types][0][type] Enum
${MODEL}[types][0][name] AssertionOperator
${MODEL}[types][0][doc] <p>This is some Doc</p>
... <p>This has was defined by assigning to __doc__.</p>

Enum Members
[Template] NONE
${exp_list} Evaluate [{"name": "equal","value": "=="},{"name": "==","value": "=="},{"name": "<","value": "<"},{"name": ">","value": ">"},{"name": "<=","value": "<="},{"name": ">=","value": ">="}]
FOR ${cur} ${exp} IN ZIP ${Model}[dataTypes][enums][0][members] ${exp_list}
FOR ${cur} ${exp} IN ZIP ${MODEL}[dataTypes][enums][0][members] ${exp_list}
Dictionaries Should Be Equal ${cur} ${exp}
END
FOR ${cur} ${exp} IN ZIP ${MODEL}[types][0][members] ${exp_list}
Dictionaries Should Be Equal ${cur} ${exp}
END

Custom types
${Model}[dataTypes][customs][0][type] Custom
${Model}[dataTypes][customs][0][name] CustomType
${Model}[dataTypes][customs][0][doc] <p>Converter method doc is used when defined.</p>
${Model}[dataTypes][customs][1][type] Custom
${Model}[dataTypes][customs][1][name] CustomType2
${Model}[dataTypes][customs][1][doc] <p>Class doc is used when converter method has no doc.</p>
${Model}[types][1][type] Custom
${Model}[types][1][name] CustomType
${Model}[types][1][doc] <p>Converter method doc is used when defined.</p>
${Model}[types][2][type] Custom
${Model}[types][2][name] CustomType2
${Model}[types][2][doc] <p>Class doc is used when converter method has no doc.</p>

Usages
${MODEL}[types][1][type] Custom
Expand Down
14 changes: 1 addition & 13 deletions atest/testdata/libdoc/DataTypesLibrary.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "DataTypesLibrary",
"doc": "<p>This Library has Data Types.</p>\n<p>It has some in <code>__init__</code> and others in the <a href=\"#Keywords\" class=\"name\">Keywords</a>.</p>\n<p>The DataTypes are the following that should be linked. <span class=\"name\">HttpCredentials</span> , <a href=\"#GeoLocation\" class=\"name\">GeoLocation</a> , <a href=\"#Small\" class=\"name\">Small</a> and <a href=\"#AssertionOperator\" class=\"name\">AssertionOperator</a>.</p>",
"version": "",
"generated": "2022-02-06 18:55:20",
"generated": "2022-02-07 01:13:37",
"type": "LIBRARY",
"scope": "TEST",
"docFormat": "HTML",
Expand Down Expand Up @@ -210,18 +210,6 @@
}
],
"dataTypes": {
"customs": [
{
"type": "Custom",
"name": "CustomType",
"doc": "<p>Converter method doc is used when defined.</p>"
},
{
"type": "Custom",
"name": "CustomType2",
"doc": "<p>Class doc is used when converter method has no doc.</p>"
}
],
"enums": [
{
"type": "Enum",
Expand Down
3 changes: 1 addition & 2 deletions atest/testdata/libdoc/DynamicLibrary.json
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,7 @@
],
"dataTypes": {
"enums": [],
"typedDicts": [],
"customs": []
"typedDicts": []
},
"types": []
}
2 changes: 0 additions & 2 deletions src/robot/libdocpkg/jsonbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ def _parse_data_types(self, data_types):
yield self._create_enum_doc(obj)
for obj in data_types['typedDicts']:
yield self._create_typed_dict_doc(obj)
for obj in data_types['customs']:
yield self._create_custom_doc(obj)

def _create_enum_doc(self, data):
return EnumDoc(name=data['name'],
Expand Down
2 changes: 0 additions & 2 deletions src/robot/libdocpkg/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,7 @@ def to_dictionary(self):
def _get_data_types(self, types):
enums = sorted(t for t in types if t.type == 'Enum')
typed_dicts = sorted(t for t in types if t.type == 'TypedDict')
customs = sorted(t for t in types if t.type == 'Custom')
return {
'customs': [t.to_dictionary(usages=False) for t in customs],
'enums': [t.to_dictionary(usages=False) for t in enums],
'typedDicts': [t.to_dictionary(usages=False) for t in typed_dicts]
}
Expand Down
2 changes: 0 additions & 2 deletions src/robot/libdocpkg/xmlbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ def _parse_data_types(self, spec):
yield self._create_enum_doc(elem)
for elem in spec.findall('datatypes/typeddicts/typeddict'):
yield self._create_typed_dict_doc(elem)
for elem in spec.findall('datatypes/customs/custom'):
yield self._create_custom_doc(elem)

def _create_enum_doc(self, elem):
return EnumDoc(name=elem.get('name'),
Expand Down
7 changes: 0 additions & 7 deletions src/robot/libdocpkg/xmlwriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,6 @@ def _write_data_types(self, types, writer):
self._write_typed_dict_items(typ_dict, writer)
writer.end('typeddict')
writer.end('typeddicts')
if customs:
writer.start('customs')
for typ in customs:
writer.start('custom', {'name': typ.name})
writer.element('doc', typ.doc)
writer.end('custom')
writer.end('customs')
writer.end('datatypes')

def _write_types(self, types, writer):
Expand Down

0 comments on commit 3a8687a

Please sign in to comment.