summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorStephen Finucane <sfinucan@redhat.com>2018-06-28 15:43:25 +0100
committerStephen Finucane <sfinucan@redhat.com>2018-07-02 11:21:47 +0100
commita34731dad1df53d9c5102161363a4bef46b62e52 (patch)
treeaeab392d53a549c474a6a9c99b1b7679fff37449 /tools
parent4ea64cad3fcc4897690bfb2c02d2b06d65db4dcf (diff)
downloadnova-a34731dad1df53d9c5102161363a4bef46b62e52.tar.gz
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>
Diffstat (limited to 'tools')
-rw-r--r--tools/placement_api_docs.py71
1 files changed, 0 insertions, 71 deletions
diff --git a/tools/placement_api_docs.py b/tools/placement_api_docs.py
deleted file mode 100644
index bec5d25942..0000000000
--- a/tools/placement_api_docs.py
+++ /dev/null
@@ -1,71 +0,0 @@
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-"""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
-
-# A humane ordering of HTTP methods for sorted output.
-ORDERED_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE']
-DEPRECATED_METHODS = [('POST', '/resource_providers/{uuid}/inventories')]
-
-
-def _header_line(map_entry):
- method, route = map_entry
- line = '.. rest_method:: %s %s' % (method, route)
- return line
-
-
-def inspect_doc(doc_files):
- """Load up doc_files and see if any routes are missing.
-
- The routes are defined in handler.ROUTE_DECLARATIONS.
- """
- routes = []
- for route in sorted(handler.ROUTE_DECLARATIONS, key=len):
- # Skip over the '' route.
- if route:
- for method in ORDERED_METHODS:
- if method in handler.ROUTE_DECLARATIONS[route]:
- routes.append((method, route))
-
- header_lines = []
- for map_entry in routes:
- if map_entry not in DEPRECATED_METHODS:
- header_lines.append(_header_line(map_entry))
-
- content_lines = []
- for doc_file in doc_files:
- with open(doc_file) as doc_fh:
- content_lines.extend(doc_fh.read().splitlines())
-
- missing_lines = []
- for line in header_lines:
- if line not in content_lines:
- missing_lines.append(line)
-
- if missing_lines:
- print('Documentation likely missing for the following routes:')
- for line in missing_lines:
- print(line)
- return 1
-
- return 0
-
-
-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))