Skip to content

Commit 112d89a

Browse files
committed
doctest_docutils(fix[regex]): Backport doctestopt_re whitespace fix
Backport: Sphinx commit ad0c343d3 (2025-01-04) Ref: sphinx-doc/sphinx@ad0c343d3 why: Doctest directive comments with leading whitespace were not recognized what: - Add [ \t]* prefix to doctestopt_re pattern - Allows doctest options like " # doctest: +SKIP" to be properly parsed - Fixes edge case where indented doctest directive comments were ignored
1 parent dc269ec commit 112d89a

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/doctest_docutils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@
3030

3131

3232
blankline_re = re.compile(r"^\s*<BLANKLINE>", re.MULTILINE)
33-
doctestopt_re = re.compile(r"#\s*doctest:.+$", re.MULTILINE)
33+
# Backported from Sphinx commit ad0c343d3 (2025-01-04).
34+
# https://github.com/sphinx-doc/sphinx/commit/ad0c343d3
35+
# Allow optional leading whitespace before doctest directive comments.
36+
doctestopt_re = re.compile(r"[ \t]*#\s*doctest:.+$", re.MULTILINE)
3437

3538

3639
def is_allowed_version(version: str, spec: str) -> bool:

0 commit comments

Comments
 (0)