Use doc8 style checker

This uses the doc8 style checker to check that the documents
conform to certain requirements, as documented at
https://pypi.python.org/pypi/doc8.

In particular, we no longer need to check for these in our test code
since they are checked via doc8:
- lines don't exceed 79 chars
- there are no trailing spaces
- there are no carriage returns

Some existing specs were modified because they had tabs or no newlines
at the end of the file.

Change-Id: If27281c7efd60c9f15ca07c723dd94a7d086c325
This commit is contained in:
Ruby Loo 2015-09-30 16:20:16 +00:00 committed by John L. Villalovos
parent 9b06d9b624
commit db259bfc1b
6 changed files with 23 additions and 39 deletions

View File

@ -143,3 +143,4 @@ http://h20628.www2.hp.com/km-ext/kmcsdirect/emr_na-c03334051-10.pdf
HP Power Capping and HP Dynamic Power Capping
http://bit.ly/1m8sbEi

View File

@ -245,3 +245,4 @@ References
* Proposed patch in python-swiftclient: https://review.openstack.org/#/c/102632/
* Glance direct_url configuration: https://github.com/openstack/glance/blob/master/etc/glance-api.conf#L89

6
test-requirements.txt Normal file
View File

@ -0,0 +1,6 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
doc8 # Apache-2.0

View File

@ -79,28 +79,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 _check_file_ext(self, filename):
self.assertTrue(filename.endswith(".rst"),
"spec's file must uses 'rst' extension.")
@ -169,9 +147,6 @@ class TestTitles(testtools.TestCase):
(data, titles) = self._get_spec_titles(filename)
self._check_titles(filename, template_titles, {}, titles)
self._check_lines_wrapping(filename, data)
self._check_no_cr(filename, data)
self._check_trailing_spaces(filename, data)
self._check_license(data)
self._check_filename(filename, data)
@ -184,7 +159,4 @@ class TestTitles(testtools.TestCase):
(data, titles) = self._get_spec_titles(filename)
self._check_titles(filename, DRAFT_REQUIRED_TITLES,
template_titles, titles)
self._check_lines_wrapping(filename, data)
self._check_no_cr(filename, data)
self._check_trailing_spaces(filename, data)
self._check_filename(filename, data)

View File

@ -8,8 +8,12 @@ usedevelop = True
install_command = pip install -U {opts} {packages}
setenv =
VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/requirements.txt
commands = python setup.py testr --slowest --testr-args='{posargs}'
deps =
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands =
python setup.py testr --slowest --testr-args='{posargs}'
doc8 specs/ doc/source README.rst
[testenv:venv]
commands = {posargs}