From 0e5aa69966d88890fc1fb4c444916be1d61d000c Mon Sep 17 00:00:00 2001 From: Niki Brown <284173+nikibrown@users.noreply.github.com> Date: Tue, 24 Mar 2026 18:22:10 +0000 Subject: [PATCH] [IMP] skip toctree in check_early_line_breaks closes odoo/documentation#17081 X-original-commit: 077cb5cc0214d6575ca79be8688c9a7a4d579b80 Signed-off-by: Antoine Vandevenne (anv) Signed-off-by: Niki Brown (nikbr) --- tests/checkers/rst_style.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/checkers/rst_style.py b/tests/checkers/rst_style.py index 706b2379ad..cdd6dbbd77 100644 --- a/tests/checkers/rst_style.py +++ b/tests/checkers/rst_style.py @@ -17,6 +17,7 @@ FORBIDDEN_HEADING_DELIMITER_RE = re.compile( ) GIT_CONFLICT_MARKERS = ['<' * 7, '>' * 7] ALLOWED_EARLY_BREAK_RE = re.compile(r'^\s*(\.\. |:\S+:\s+)', re.IGNORECASE) # Contains markup. +TOCTREE_DIRECTIVE_RE = re.compile(r'^\s*\.\.\s+toctree::\s*$', re.IGNORECASE) @sphinxlint.checker('.rst') @@ -136,8 +137,27 @@ def check_early_line_breaks(file, lines, options=None): else: return next_line_.split(' ', 1)[0] + # Skip indented body lines after .. toctree:: (path lists, :maxdepth:, etc.) + toctree_skip = set() + in_toctree = False + for i, line in enumerate(lines): + if TOCTREE_DIRECTIVE_RE.match(line): + in_toctree = True + continue + if not in_toctree: + continue + stripped = line.strip() + if stripped == '': + continue + if line.startswith(' ') or line.startswith('\t'): + toctree_skip.add(i) + else: + in_toctree = False + for lno, line in enumerate(lines): if lno + 1 < len(lines): + if lno in toctree_skip or (lno + 1) in toctree_skip: + continue next_line = lines[lno + 1] if ( is_valid_line(line, ('+', '| '))