Browse Source

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>
changes/26/578826/3
Stephen Finucane 3 years ago
parent
commit
a34731dad1
  1. 0
      placement-api-ref/ext/__init__.py
  2. 21
      placement-api-ref/ext/validator.py
  3. 5
      placement-api-ref/source/conf.py
  4. 2
      tox.ini

0
placement-api-ref/ext/__init__.py

21
tools/placement_api_docs.py → placement-api-ref/ext/validator.py

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

5
placement-api-ref/source/conf.py

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

2
tox.ini

@ -182,8 +182,6 @@ description =
Generate the Placement API ref. Called from CI scripts to test and publish to developer.openstack.org.
deps = {[testenv:docs]deps}
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
sphinx-build -W -b html -d placement-api-ref/build/doctrees placement-api-ref/source placement-api-ref/build/html

Loading…
Cancel
Save