Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add arguments to variables #6

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1191,8 +1191,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}"""
)