|
|
|
@ -12,7 +12,6 @@
|
|
|
|
|
|
|
|
|
|
import glob |
|
|
|
|
import os |
|
|
|
|
import re |
|
|
|
|
|
|
|
|
|
import docutils.core |
|
|
|
|
import testtools |
|
|
|
@ -62,30 +61,6 @@ class TestTitles(testtools.TestCase):
|
|
|
|
|
self.fail("While checking '%s':\n %s" |
|
|
|
|
% (filename, "\n ".join(msgs))) |
|
|
|
|
|
|
|
|
|
def _check_lines_wrapping(self, tpl, raw): |
|
|
|
|
for i, line in enumerate(raw.split("\n")): |
|
|
|
|
if "http://" in line or "https://" in line: |
|
|
|
|
continue |
|
|
|
|
self.assertTrue( |
|
|
|
|
len(line) < 80, |
|
|
|
|
msg="%s:%d: Line limited to a maximum of 79 characters." % |
|
|
|
|
(tpl, i+1)) |
|
|
|
|
|
|
|
|
|
def _check_no_cr(self, tpl, raw): |
|
|
|
|
matches = re.findall('\r', raw) |
|
|
|
|
self.assertEqual( |
|
|
|
|
len(matches), 0, |
|
|
|
|
"Found %s literal carriage returns in file %s" % |
|
|
|
|
(len(matches), tpl)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _check_trailing_spaces(self, tpl, raw): |
|
|
|
|
for i, line in enumerate(raw.split("\n")): |
|
|
|
|
trailing_spaces = re.findall(" +$", line) |
|
|
|
|
self.assertEqual(len(trailing_spaces),0, |
|
|
|
|
"Found trailing spaces on line %s of %s" % (i+1, tpl)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_template(self): |
|
|
|
|
filenames = glob.glob("guidelines/*") |
|
|
|
|
for filename in filenames: |
|
|
|
@ -100,9 +75,4 @@ class TestTitles(testtools.TestCase):
|
|
|
|
|
with open(filename) as f: |
|
|
|
|
data = f.read() |
|
|
|
|
|
|
|
|
|
spec = docutils.core.publish_doctree(data) |
|
|
|
|
self._check_no_cr(filename, data) |
|
|
|
|
self._check_trailing_spaces(filename, data) |
|
|
|
|
|
|
|
|
|
if filename.endswith(".rst"): |
|
|
|
|
self._check_lines_wrapping(filename, data) |
|
|
|
|
docutils.core.publish_doctree(data) |
|
|
|
|