[placement] Fix placement-api-ref check tool

Some time ago the placement-api-ref source structure was changed
(Ia2fd62ae7f401cad34ee7c2b355c9a5ab1c93f6b) to use inc-files istead of
putting all in index.rst, but that change broke placement_api_docs.py.

This change modifies placement_api_docs.py to go through all *.inc files
in placement-api-ref directory and scan for the "rest method" header.

Change-Id: I60150ab51173934f848662499dcf6af18625697e
This commit is contained in:
Andrey Volkov 2017-04-12 15:13:23 +03:00
parent 640b152004
commit 90cabd0c8c
2 changed files with 12 additions and 7 deletions

View File

@ -11,6 +11,7 @@
# under the License. # under the License.
"""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 sys import sys
from nova.api.openstack.placement import handler from nova.api.openstack.placement import handler
@ -25,8 +26,8 @@ def _header_line(map_entry):
return line return line
def inspect_doc(doc_file): def inspect_doc(doc_files):
"""Load up doc_file 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.
""" """
@ -42,8 +43,10 @@ def inspect_doc(doc_file):
for map_entry in routes: for map_entry in routes:
header_lines.append(_header_line(map_entry)) header_lines.append(_header_line(map_entry))
with open(doc_file) as doc_fh: content_lines = []
content_lines = doc_fh.read().splitlines() for doc_file in doc_files:
with open(doc_file) as doc_fh:
content_lines.extend(doc_fh.read().splitlines())
missing_lines = [] missing_lines = []
for line in header_lines: for line in header_lines:
@ -60,5 +63,7 @@ def inspect_doc(doc_file):
if __name__ == '__main__': if __name__ == '__main__':
doc_file = sys.argv[1] path = sys.argv[1]
sys.exit(inspect_doc(doc_file)) 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

@ -149,7 +149,7 @@ commands =
# TODO(cdent): Get rid of the leading '-' after all the existing # TODO(cdent): Get rid of the leading '-' after all the existing
# routes have been documented. It causes the non-zero exit code to # routes have been documented. It causes the non-zero exit code to
# ignored. # ignored.
- python tools/placement_api_docs.py placement-api-ref/source/index.rst - 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