summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Stoelinga <sammiestoel@gmail.com>2015-08-21 23:16:53 +0800
committerSam Stoelinga <sammiestoel@gmail.com>2015-08-21 23:51:14 +0800
commit64f22e443f826c040a0783535667b20c0919f7a6 (patch)
tree1b017f92122837705751963ff43cb2dabd3aca52
parent062bf244b69e5e3ced3ce78c6821f9008a182cff (diff)
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
Notes
Notes (review): Verified+2: Jenkins Code-Review+2: Joshua Harlow <harlowja@yahoo-inc.com> Workflow+1: Joshua Harlow <harlowja@yahoo-inc.com> Code-Review+1: Julien Danjou <julien@danjou.info> Code-Review+1: Andreas Jaeger <jaegerandi@gmail.com> Submitted-by: Jenkins Submitted-at: Tue, 25 Aug 2015 16:53:09 +0000 Reviewed-on: https://review.openstack.org/215685 Project: stackforge/doc8 Branch: refs/heads/master
-rw-r--r--doc8/checks.py2
-rw-r--r--doc8/tests/test_checks.py19
2 files changed, 20 insertions, 1 deletions
diff --git a/doc8/checks.py b/doc8/checks.py
index 9d8578a..993183f 100644
--- a/doc8/checks.py
+++ b/doc8/checks.py
@@ -202,7 +202,7 @@ class CheckMaxLineLength(ContentCheck):
202 # for unknown directives, so we have to do it manually). 202 # for unknown directives, so we have to do it manually).
203 directives = [] 203 directives = []
204 for i, line in enumerate(lines): 204 for i, line in enumerate(lines):
205 if re.match(r"^..\s(.*?)::\s*", line): 205 if re.match(r"^\s*..\s(.*?)::\s*", line):
206 directives.append((i, find_directive_end(i, lines))) 206 directives.append((i, find_directive_end(i, lines)))
207 elif re.match(r"^::\s*$", line): 207 elif re.match(r"^::\s*$", line):
208 directives.append((i, find_directive_end(i, lines))) 208 directives.append((i, find_directive_end(i, lines)))
diff --git a/doc8/tests/test_checks.py b/doc8/tests/test_checks.py
index 2d040c9..0011d79 100644
--- a/doc8/tests/test_checks.py
+++ b/doc8/tests/test_checks.py
@@ -105,6 +105,25 @@ test
105 errors = list(check.report_iter(parsed_file)) 105 errors = list(check.report_iter(parsed_file))
106 self.assertEqual(0, len(errors)) 106 self.assertEqual(0, len(errors))
107 107
108 def test_ignore_code_block(self):
109 conf = {
110 'max_line_length': 79,
111 'allow_long_titles': True,
112 }
113 with tempfile.NamedTemporaryFile(suffix='.rst') as fh:
114 fh.write(b'List which contains items with code-block\n'
115 b'- this is a list item\n\n'
116 b' .. code-block:: ini\n\n'
117 b' this line exceeds 80 chars but should be ignored'
118 b'this line exceeds 80 chars but should be ignored'
119 b'this line exceeds 80 chars but should be ignored')
120 fh.flush()
121
122 parsed_file = parser.ParsedFile(fh.name, encoding='utf-8')
123 check = checks.CheckMaxLineLength(conf)
124 errors = list(check.report_iter(parsed_file))
125 self.assertEqual(0, len(errors))
126
108 def test_unsplittable_length(self): 127 def test_unsplittable_length(self):
109 content = b""" 128 content = b"""
110=== 129===