diff --git a/placement-api-ref/ext/__init__.py b/placement-api-ref/ext/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tools/placement_api_docs.py b/placement-api-ref/ext/validator.py similarity index 84% rename from tools/placement_api_docs.py rename to placement-api-ref/ext/validator.py index bec5d2594261..44a4cef36af3 100644 --- a/tools/placement_api_docs.py +++ b/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) diff --git a/placement-api-ref/source/conf.py b/placement-api-ref/source/conf.py index f52d3fdbd0c6..d4766be180de 100644 --- a/placement-api-ref/source/conf.py +++ b/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 ---------------------------------------------------- diff --git a/tox.ini b/tox.ini index a6e582864472..e1c0823a5ce9 100644 --- a/tox.ini +++ b/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