From 70d20fc887a778a7e5fa256a367487ad7b7d5efd Mon Sep 17 00:00:00 2001 From: "Antoine Vandevenne (anv)" Date: Wed, 5 Mar 2025 12:50:09 +0000 Subject: [PATCH] [FIX] tests: don't confuse separators for heading delimiters RST separators (`-----`) look similar to H3 delimiters that use the same `-` character, but separators' length should not be checked. X-original-commit: a54a68823f3844a777e0bfcd3dc8ecd4538adff8 Part-of: odoo/documentation#12270 Signed-off-by: Antoine Vandevenne (anv) --- tests/checkers/rst_style.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/checkers/rst_style.py b/tests/checkers/rst_style.py index 1e9304a8e..c8ad549d8 100644 --- a/tests/checkers/rst_style.py +++ b/tests/checkers/rst_style.py @@ -74,7 +74,8 @@ def check_min_one_main_heading(file, lines, options=None): def check_heading_delimiters_length(file, lines, options=None): """ Check that heading delimiters have the same length as their heading. """ for lno, line in enumerate(lines): - if HEADING_DELIMITER_RE.search(line): # The line is a heading delimiter. + previous_line = lno >= 1 and lines[lno - 1] + if HEADING_DELIMITER_RE.search(line) and previous_line != '\n': # Heading delimiter found. if MAIN_HEADING_RE.search(''.join(lines[lno:lno+3])): # Upper delimiter of h1. heading_lno = lno + 1 else: # Lower delimiter of a heading of any level. @@ -87,7 +88,8 @@ def check_heading_delimiters_length(file, lines, options=None): def check_heading_spacing(file, lines, options=None): """ Check that headings are preceded and followed by at least one blank line. """ for lno, line in enumerate(lines): - if HEADING_DELIMITER_RE.search(line): # The line is a heading delimiter. + previous_line = lno > 1 and lines[lno - 1] + if HEADING_DELIMITER_RE.search(line) and previous_line != '\n': # Heading delimiter found. if MAIN_HEADING_RE.search(''.join(lines[lno:lno+3])): # Upper delimiter of h1. continue # We handle this heading via its lower delimiter.