Skip to content

Commit 6940404

Browse files
Fix pulling from comments
1 parent 02d2f07 commit 6940404

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Tools/check-c-api-docs/main.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
SIMPLE_MACRO_REGEX = re.compile(r"# *define *(\w+)(\(.+\))? ")
99
SIMPLE_INLINE_REGEX = re.compile(r"static inline .+( |\n)(\w+)")
1010
SIMPLE_DATA_REGEX = re.compile(r"PyAPI_DATA\(.+\) (\w+)")
11+
C_BLOCK_COMMENT_REGEX = re.compile(r"/\*.*?\*/", re.DOTALL)
12+
C_LINE_COMMENT_REGEX = re.compile(r"//.*$", re.MULTILINE)
1113

1214
CPYTHON = Path(__file__).parent.parent.parent
1315
INCLUDE = CPYTHON / "Include"
@@ -97,6 +99,9 @@ def scan_file_for_docs(filename: str, text: str) -> tuple[list[str], list[str]]:
9799
documented_ignored: list[str] = []
98100
colors = _colorize.get_colors()
99101

102+
text = C_BLOCK_COMMENT_REGEX.sub("", text)
103+
text = C_LINE_COMMENT_REGEX.sub("", text)
104+
100105
def check_for_name(name: str) -> None:
101106
documented = is_documented(name)
102107
if documented and (name in IGNORED):

0 commit comments

Comments
 (0)