Skip to content

Commit 93f1bf3

Browse files
authored
Merge pull request #192 from OpenMS/logging_for_comments
fix handling of multiple multi-line annotations with only an empty li…
2 parents f8647c5 + 7213164 commit 93f1bf3

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

autowrap/PXDParser.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,11 @@ def _parse_multiline_annotations(lines: Collection[str]) -> AnnotDict:
137137
key = line
138138
result[key] = True
139139
else:
140-
break
140+
# Allow empty lines between annotations, but stop on non-empty non-comment lines
141+
if line.strip():
142+
break
143+
# Continue parsing if it's just an empty line
144+
in_annot_context = False
141145

142146
# make sure wrap-doc is always a Code object
143147
if "wrap-doc" in result.keys():

tests/test_pxd_parser.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,3 +612,33 @@ def test_multiline_docs():
612612
assert result["wrap-doc"].content[0] == "first line"
613613
assert result["wrap-doc"].content[1] == " second line indented"
614614
assert result["wrap-doc"].content[2] == ""
615+
616+
617+
def test_consecutive_multiline_annotations():
618+
"""Test that consecutive multiline annotations separated by empty lines are parsed correctly."""
619+
(cdcl,) = autowrap.PXDParser.parse_str(
620+
"""
621+
cdef extern from "*":
622+
cdef cppclass LinearInterpolation[V,W]:
623+
# wrap-doc:
624+
# Linear interpolation for gridded data
625+
# Supports various interpolation methods
626+
627+
# wrap-instances:
628+
# LinearInterpolation := LinearInterpolation[double, double]
629+
630+
pass
631+
"""
632+
)
633+
634+
# Verify both annotations were parsed
635+
assert "wrap-doc" in cdcl.annotations
636+
assert "wrap-instances" in cdcl.annotations
637+
638+
# Verify wrap-doc content
639+
expected_doc_content = ["Linear interpolation for gridded data", "Supports various interpolation methods"]
640+
assert cdcl.annotations["wrap-doc"].content == expected_doc_content
641+
642+
# Verify wrap-instances content
643+
expected_instances = ["LinearInterpolation := LinearInterpolation[double, double]"]
644+
assert cdcl.annotations["wrap-instances"] == expected_instances

0 commit comments

Comments
 (0)