From b3ad07415399a90678f3de00ac921ee518d8dab3 Mon Sep 17 00:00:00 2001 From: Yurii Motov Date: Mon, 5 Jan 2026 11:19:38 +0100 Subject: [PATCH] Fix comment regexes (require leading whitespace if comment starts not at the line start) --- scripts/doc_parsing_utils.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/doc_parsing_utils.py b/scripts/doc_parsing_utils.py index 3d5bb1b834..5da91122e1 100644 --- a/scripts/doc_parsing_utils.py +++ b/scripts/doc_parsing_utils.py @@ -26,8 +26,11 @@ HTML_ATTR_RE = re.compile(r'(\w+)\s*=\s*([\'"])(.*?)\2') CODE_BLOCK_LANG_RE = re.compile(r"^```([\w-]*)", re.MULTILINE) -SLASHES_COMMENT_RE = re.compile(r"^(?P.*?)(?P\s*// .*)?$") -HASH_COMMENT_RE = re.compile(r"^(?P.*?)(?P\s*# .*)?$") +SLASHES_COMMENT_RE = re.compile( + r"^(?P.*?)(?P(?:(?<= )// .*)|(?:^// .*))?$" +) + +HASH_COMMENT_RE = re.compile(r"^(?P.*?)(?P(?:(?<= )# .*)|(?:^# .*))?$") class CodeIncludeInfo(TypedDict):