From 3abffb4fd7467125366b99fe6c6450a93a8b72ff Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Thu, 19 Mar 2020 11:39:54 +0100 Subject: [PATCH] Use doc8 to verify rst instead of custom tests Fix a disproportionally long line in dns-sd. Change-Id: I9137ce1780e971824bffdd4e6557ddeb44c4db0b --- .zuul.yaml | 2 ++ guidelines/dns-sd.rst | 2 +- requirements.txt | 1 + tests/test_titles.py | 32 +------------------------------- tox.ini | 7 ++++++- 5 files changed, 11 insertions(+), 33 deletions(-) diff --git a/.zuul.yaml b/.zuul.yaml index 9919896..efa2267 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -4,6 +4,8 @@ check: jobs: - openstack-tox-py37 + - openstack-tox-linters gate: jobs: - openstack-tox-py37 + - openstack-tox-linters diff --git a/guidelines/dns-sd.rst b/guidelines/dns-sd.rst index d28f0e8..0b41584 100644 --- a/guidelines/dns-sd.rst +++ b/guidelines/dns-sd.rst @@ -81,7 +81,7 @@ discover the ``auth_url`` to use. I issue a DNS request to retrieve ``SRV`` and ``TXT`` records:: - $ nslookup -query=any "identity._openstack._tcp.mystack.example.com" master + $ nslookup -query=any "identity._openstack._tcp.mystack.example.com" identity._openstack._tcp.mystack.example.com service = 0 0 443 os.mystack.example.com identity._openstack._tcp.mystack.example.com text = "txtvers=1" "path=/" diff --git a/requirements.txt b/requirements.txt index 70d369b..2d0c9b9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,7 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. pbr>=1.0 +doc8>=0.6.0 # Apache-2.0 openstackdocstheme>=1.18.1 # Apache-2.0 sphinx!=1.6.6,!=1.6.7,>=1.6.2,<2.0.0;python_version=='2.7' # BSD sphinx!=1.6.6,!=1.6.7,>=1.6.2;python_version>='3.4' # BSD diff --git a/tests/test_titles.py b/tests/test_titles.py index 761ef78..1b76480 100644 --- a/tests/test_titles.py +++ b/tests/test_titles.py @@ -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) diff --git a/tox.ini b/tox.ini index 65944ca..a9b872f 100644 --- a/tox.ini +++ b/tox.ini @@ -2,7 +2,7 @@ # Hold back to 1.4, since that's what's in Fedora 20 repos # and we don't need anything newer for nova-specs tests minversion = 1.4 -envlist = docs,py37 +envlist = docs,py37,linters skipsdist = True [testenv] @@ -13,6 +13,11 @@ install_command = pip install -U {opts} {packages} deps = -r{toxinidir}/requirements.txt commands = stestr run --slowest {posargs} +[testenv:linters] +commands = + # Check the *.rst files + doc8 README.rst guidelines + [testenv:venv] commands = {posargs}