mirror of
https://github.com/odoo/documentation.git
synced 2026-03-27 14:10:23 +07:00
[IMP] skip toctree in check_early_line_breaks
closes odoo/documentation#17088
X-original-commit: 077cb5cc02
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
Signed-off-by: Niki Brown (nikbr) <nikbr@odoo.com>
This commit is contained in:
@@ -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, ('+', '| '))
|
||||
|
||||
Reference in New Issue
Block a user