Convert 'placement_api_docs' into a Sphinx extension

This ensures it will get run in the gate.

Change-Id: I923c39d3115b595b8de94e85d2977eb7782d98e2
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
Stephen Finucane 2018-06-28 15:43:25 +01:00
parent 4ea64cad3f
commit a34731dad1
4 changed files with 14 additions and 14 deletions

View File

View File

@ -12,7 +12,6 @@
"""Test to see if docs exists for routes and methods in the placement API.""" """Test to see if docs exists for routes and methods in the placement API."""
import os import os
import sys
from nova.api.openstack.placement import handler from nova.api.openstack.placement import handler
@ -27,11 +26,14 @@ def _header_line(map_entry):
return line return line
def inspect_doc(doc_files): def inspect_doc(app):
"""Load up doc_files and see if any routes are missing. """Load up doc_files and see if any routes are missing.
The routes are defined in handler.ROUTE_DECLARATIONS. The routes are defined in handler.ROUTE_DECLARATIONS.
""" """
doc_files = [os.path.join(app.srcdir, file)
for file in os.listdir(app.srcdir) if file.endswith(".inc")]
routes = [] routes = []
for route in sorted(handler.ROUTE_DECLARATIONS, key=len): for route in sorted(handler.ROUTE_DECLARATIONS, key=len):
# Skip over the '' route. # Skip over the '' route.
@ -56,16 +58,11 @@ def inspect_doc(doc_files):
missing_lines.append(line) missing_lines.append(line)
if missing_lines: if missing_lines:
print('Documentation likely missing for the following routes:') msg = ['Documentation likely missing for the following routes:', '']
for line in missing_lines: for line in missing_lines:
print(line) msg.append(line)
return 1 raise ValueError('\n'.join(msg))
return 0
if __name__ == '__main__': def setup(app):
path = sys.argv[1] app.connect('builder-inited', inspect_doc)
doc_files = [os.path.join(path, file)
for file in os.listdir(path) if file.endswith(".inc")]
sys.exit(inspect_doc(doc_files))

View File

@ -22,12 +22,17 @@
# All configuration values have a default; values that are commented out # All configuration values have a default; values that are commented out
# serve to show the default. # serve to show the default.
import os
import sys
from nova.version import version_info from nova.version import version_info
sys.path.insert(0, os.path.abspath('../'))
extensions = [ extensions = [
'openstackdocstheme', 'openstackdocstheme',
'os_api_ref', 'os_api_ref',
'ext.validator',
] ]
# -- General configuration ---------------------------------------------------- # -- General configuration ----------------------------------------------------

View File

@ -182,8 +182,6 @@ description =
Generate the Placement API ref. Called from CI scripts to test and publish to developer.openstack.org. Generate the Placement API ref. Called from CI scripts to test and publish to developer.openstack.org.
deps = {[testenv:docs]deps} deps = {[testenv:docs]deps}
commands = commands =
# Check that all placement api routes are in the documentation
python tools/placement_api_docs.py placement-api-ref/source/
rm -rf placement-api-ref/build rm -rf placement-api-ref/build
sphinx-build -W -b html -d placement-api-ref/build/doctrees placement-api-ref/source placement-api-ref/build/html sphinx-build -W -b html -d placement-api-ref/build/doctrees placement-api-ref/source placement-api-ref/build/html