Fix issue of checking max_len for directives
This patch changes the regex to also match directives which start with whitespace. Closes-Bug: #1487302 Change-Id: I4c3168228164d865cc31dfd24160c41267aeb016
This commit is contained in:
parent
062bf244b6
commit
64f22e443f
|
@ -202,7 +202,7 @@ class CheckMaxLineLength(ContentCheck):
|
||||||
# for unknown directives, so we have to do it manually).
|
# for unknown directives, so we have to do it manually).
|
||||||
directives = []
|
directives = []
|
||||||
for i, line in enumerate(lines):
|
for i, line in enumerate(lines):
|
||||||
if re.match(r"^..\s(.*?)::\s*", line):
|
if re.match(r"^\s*..\s(.*?)::\s*", line):
|
||||||
directives.append((i, find_directive_end(i, lines)))
|
directives.append((i, find_directive_end(i, lines)))
|
||||||
elif re.match(r"^::\s*$", line):
|
elif re.match(r"^::\s*$", line):
|
||||||
directives.append((i, find_directive_end(i, lines)))
|
directives.append((i, find_directive_end(i, lines)))
|
||||||
|
|
|
@ -105,6 +105,25 @@ test
|
||||||
errors = list(check.report_iter(parsed_file))
|
errors = list(check.report_iter(parsed_file))
|
||||||
self.assertEqual(0, len(errors))
|
self.assertEqual(0, len(errors))
|
||||||
|
|
||||||
|
def test_ignore_code_block(self):
|
||||||
|
conf = {
|
||||||
|
'max_line_length': 79,
|
||||||
|
'allow_long_titles': True,
|
||||||
|
}
|
||||||
|
with tempfile.NamedTemporaryFile(suffix='.rst') as fh:
|
||||||
|
fh.write(b'List which contains items with code-block\n'
|
||||||
|
b'- this is a list item\n\n'
|
||||||
|
b' .. code-block:: ini\n\n'
|
||||||
|
b' this line exceeds 80 chars but should be ignored'
|
||||||
|
b'this line exceeds 80 chars but should be ignored'
|
||||||
|
b'this line exceeds 80 chars but should be ignored')
|
||||||
|
fh.flush()
|
||||||
|
|
||||||
|
parsed_file = parser.ParsedFile(fh.name, encoding='utf-8')
|
||||||
|
check = checks.CheckMaxLineLength(conf)
|
||||||
|
errors = list(check.report_iter(parsed_file))
|
||||||
|
self.assertEqual(0, len(errors))
|
||||||
|
|
||||||
def test_unsplittable_length(self):
|
def test_unsplittable_length(self):
|
||||||
content = b"""
|
content = b"""
|
||||||
===
|
===
|
||||||
|
|
Loading…
Reference in New Issue