Skip to content

Commit 7dfe473

Browse files
committed
Doxygen comments were being discarded when an attribute was encountered
1 parent 77d2c98 commit 7dfe473

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

CppHeaderParser/CppHeaderParser.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2895,9 +2895,11 @@ def __init__(self, headerFileName, argType="file", encoding=None, **kwargs):
28952895
self._parse_template()
28962896
continue
28972897
elif tok.value == "alignas":
2898+
self._doxygen_cache = self.lex.get_doxygen()
28982899
self._parse_attribute_specifier_seq(tok)
28992900
continue
29002901
elif tok.value == "__attribute__":
2902+
self._doxygen_cache = self.lex.get_doxygen()
29012903
self._parse_gcc_attribute()
29022904
continue
29032905
elif not self.stack and tok.value == "static_assert":
@@ -2906,6 +2908,7 @@ def __init__(self, headerFileName, argType="file", encoding=None, **kwargs):
29062908
continue
29072909

29082910
elif tok.type == "DBL_LBRACKET":
2911+
self._doxygen_cache = self.lex.get_doxygen()
29092912
self._parse_attribute_specifier_seq(tok)
29102913
continue
29112914

@@ -3076,7 +3079,7 @@ def __init__(self, headerFileName, argType="file", encoding=None, **kwargs):
30763079

30773080
newNsLen = len(self.nameStack)
30783081
if nslen != newNsLen and newNsLen == 1:
3079-
if not self.curTemplate:
3082+
if not self._doxygen_cache:
30803083
self._doxygen_cache = self.lex.get_doxygen()
30813084

30823085
except Exception as e:
@@ -3471,7 +3474,7 @@ def _evaluate_stack(self, token=None):
34713474

34723475
# its a little confusing to have some if/else above return and others not, and then clearning the nameStack down here
34733476
self.nameStack = []
3474-
self.lex.doxygenCommentCache = ""
3477+
self._doxygen_cache = None
34753478
self.curTemplate = None
34763479

34773480
def _parse_template(self):

test/test_CppHeaderParser.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3414,6 +3414,10 @@ def setUp(self):
34143414
class
34153415
C2 {};
34163416
3417+
/// hasattr comment
3418+
[[nodiscard]]
3419+
int hasattr();
3420+
34173421
""",
34183422
"string",
34193423
)
@@ -3443,6 +3447,11 @@ def test_cls2(self):
34433447
self.assertEqual("C2", c["name"])
34443448
self.assertEqual("/// template comment", c["doxygen"])
34453449

3450+
def test_hasattr(self):
3451+
fn = self.cppHeader.functions[1]
3452+
self.assertEqual("hasattr", fn["name"])
3453+
self.assertEqual("/// hasattr comment", fn["doxygen"])
3454+
34463455

34473456
class EnumParameter_TestCase(unittest.TestCase):
34483457
def setUp(self):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy