Skip to content

Commit

Permalink
Judicious doc: ensure that parameters is always a list
Browse files Browse the repository at this point in the history
Even for functions without parameters or with one single parameter.
  • Loading branch information
lucach committed Sep 9, 2024
1 parent e520125 commit f6e97f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion docs/judicious.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
<xsl:apply-templates select="desc_content/paragraph[position() > 0]"/>
<xsl:apply-templates select="desc_content/figure"/>
</description>
<xsl:apply-templates select="desc_signature/desc_parameterlist/desc_parameter"/>
<parameters>
<xsl:apply-templates select="desc_signature/desc_parameterlist/desc_parameter"/>
</parameters>
<xsl:if test="desc_signature/desc_returns">
<returnValue>
<type>
Expand Down
6 changes: 3 additions & 3 deletions docs/judicious_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def plural(element_type):


def postprocessor(path, key, value):
if key == "parameter":
return plural(key), value
if key == "parameters":
return key, value["parameter"] if value is not None else []
if key == "sideEffects":
return key, True if value == "true" else False
return key, value
Expand All @@ -43,7 +43,7 @@ def pytamaro_module(folder_name):
for filename in languagedir.glob("*.xml"):
xml = ET.parse(filename)
new_xml = xslt_transform(xml)
new_xml_as_dict = xmltodict.parse(ET.tostring(new_xml, encoding='unicode'), force_list=['element', 'p'], postprocessor=postprocessor)
new_xml_as_dict = xmltodict.parse(ET.tostring(new_xml, encoding='unicode'), force_list=['element', 'p', 'parameter'], postprocessor=postprocessor)
docs["elements"].extend(new_xml_as_dict['elements']["element"])
output_path = OUTPUT_DIR / (module_name + ".json")
with open(output_path, "w") as f:
Expand Down

0 comments on commit f6e97f5

Please sign in to comment.