Skip to content

Commit

Permalink
Add arguments to variables
Browse files Browse the repository at this point in the history
As raised by @lurch, variables with a non-empty argsstring are lacking
that part of their definition in the "Variables" section of the
documentation but not the "Variable Documentation" section as that uses
a different element to fetch the full definition.
  • Loading branch information
mudge committed Aug 15, 2024
1 parent d7f5ab7 commit da3821a
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 2 deletions.
6 changes: 5 additions & 1 deletion nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1189,8 +1189,12 @@ def to_asciidoc(self, **kwargs):
variable = ["`"]
variable.append(memberdef.child("type").to_asciidoc(**kwargs))
variable.append(
f" <<{memberdef.id},{escape_text(memberdef.text('name'))}>>`:: "
f" <<{memberdef.id},{escape_text(memberdef.text('name'))}>>"
)
argsstring = memberdef.text("argsstring")
if argsstring:
variable.append(argsstring)
variable.append("`:: ")
briefdescription = memberdef.child("briefdescription").to_asciidoc(**kwargs)
if briefdescription:
variable.append(briefdescription)
Expand Down
63 changes: 62 additions & 1 deletion tests/test_variable_sectiondef_node.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# pylint: disable=line-too-long

from textwrap import dedent
from bs4 import BeautifulSoup
from doxygentoasciidoc.nodes import VariableSectiondefNode
Expand Down Expand Up @@ -30,7 +32,7 @@ def test_to_asciidoc():
"""\
===== Variables
`uint32_t <<float_init_rom_8c_1aea98df4cf9adff2a025dc4a09c814986,sf_table>>`:: {empty}"""
`uint32_t <<float_init_rom_8c_1aea98df4cf9adff2a025dc4a09c814986,sf_table>>[SF_TABLE_V2_SIZE/2]`:: {empty}"""
)


Expand Down Expand Up @@ -66,3 +68,62 @@ def test_to_details_asciidoc():
[.memname]`uint32_t sf_table[SF_TABLE_V2_SIZE/2]`"""
)


def test_bug():
xml = """\
<sectiondef kind="var">
<memberdef kind="variable" id="group__cyw43__driver_1gafe7528793baa39a05a1c4ff55f5b5807" prot="public" static="no" extern="yes" mutable="no">
<type><ref refid="struct__cyw43__t" kindref="compound">cyw43_t</ref></type>
<definition>cyw43_t cyw43_state</definition>
<argsstring></argsstring>
<name>cyw43_state</name>
<briefdescription>
</briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="cyw43.h" line="154" column="16" bodyfile="cyw43_ctrl.c" bodystart="68" bodyend="-1" declfile="cyw43.h" declline="154" declcolumn="16"/>
</memberdef>
<memberdef kind="variable" id="group__cyw43__driver_1ga65550517babd8db2d2a052f41de6ae33" prot="public" static="no" extern="yes" mutable="no">
<type>void(*</type>
<definition>void(* cyw43_poll) (void)</definition>
<argsstring>)(void)</argsstring>
<name>cyw43_poll</name>
<briefdescription>
</briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="cyw43.h" line="155" column="8" bodyfile="cyw43_ctrl.c" bodystart="69" bodyend="-1" declfile="cyw43.h" declline="155" declcolumn="8"/>
</memberdef>
<memberdef kind="variable" id="group__cyw43__driver_1ga8345872c237308a5e4e984060f9f399f" prot="public" static="no" extern="yes" mutable="no">
<type>uint32_t</type>
<definition>uint32_t cyw43_sleep</definition>
<argsstring></argsstring>
<name>cyw43_sleep</name>
<briefdescription>
</briefdescription>
<detaileddescription>
</detaileddescription>
<inbodydescription>
</inbodydescription>
<location file="cyw43.h" line="156" column="17" bodyfile="cyw43_ctrl.c" bodystart="70" bodyend="-1" declfile="cyw43.h" declline="156" declcolumn="17"/>
</memberdef>
</sectiondef>
"""

asciidoc = VariableSectiondefNode(
BeautifulSoup(xml, "xml").sectiondef
).to_asciidoc()

assert asciidoc == dedent(
"""\
===== Variables
`<<struct_cyw43_t,cyw43_t>> <<group_cyw43_driver_1gafe7528793baa39a05a1c4ff55f5b5807,cyw43_state>>`:: {empty}
`void(++*++ <<group_cyw43_driver_1ga65550517babd8db2d2a052f41de6ae33,cyw43_poll>>)(void)`:: {empty}
`uint32_t <<group_cyw43_driver_1ga8345872c237308a5e4e984060f9f399f,cyw43_sleep>>`:: {empty}"""
)

0 comments on commit da3821a

Please sign in to comment.