From b1cf4b7f7a2b358853d848844023f83a10a77bae Mon Sep 17 00:00:00 2001 From: Paul Mucur Date: Thu, 15 Aug 2024 14:23:44 +0100 Subject: [PATCH] Add arguments to variables 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. --- nodes.py | 6 ++- tests/test_variable_sectiondef_node.py | 63 +++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/nodes.py b/nodes.py index 14b8a0e..8974a8e 100644 --- a/nodes.py +++ b/nodes.py @@ -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) diff --git a/tests/test_variable_sectiondef_node.py b/tests/test_variable_sectiondef_node.py index c9a7119..4eac0f6 100644 --- a/tests/test_variable_sectiondef_node.py +++ b/tests/test_variable_sectiondef_node.py @@ -1,3 +1,5 @@ +# pylint: disable=line-too-long + from textwrap import dedent from bs4 import BeautifulSoup from doxygentoasciidoc.nodes import VariableSectiondefNode @@ -30,7 +32,7 @@ def test_to_asciidoc(): """\ ===== Variables - `uint32_t <>`:: {empty}""" + `uint32_t <>[SF_TABLE_V2_SIZE/2]`:: {empty}""" ) @@ -66,3 +68,62 @@ def test_to_details_asciidoc(): [.memname]`uint32_t sf_table[SF_TABLE_V2_SIZE/2]`""" ) + + +def test_bug(): + xml = """\ + + + cyw43_t + cyw43_t cyw43_state + + cyw43_state + + + + + + + + + + void(* + void(* cyw43_poll) (void) + )(void) + cyw43_poll + + + + + + + + + + uint32_t + uint32_t cyw43_sleep + + cyw43_sleep + + + + + + + + + + """ + + asciidoc = VariableSectiondefNode( + BeautifulSoup(xml, "xml").sectiondef + ).to_asciidoc() + + assert asciidoc == dedent( + """\ + ===== Variables + + `<> <>`:: {empty} + `void(++*++ <>)(void)`:: {empty} + `uint32_t <>`:: {empty}""" + )