From a7927d59b8fe18bd10d8b66532a5119418164153 Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Tue, 23 Aug 2016 14:41:15 -0700 Subject: [PATCH] Fixing docs-rtd tox rule. It was previously broken because module verification assumed the docs were built in the _build directory. --- scripts/verify_included_modules.py | 17 ++++++++++++----- tox.ini | 4 ++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/scripts/verify_included_modules.py b/scripts/verify_included_modules.py index 7fe3471c9e1e5..3b643e8fc9932 100644 --- a/scripts/verify_included_modules.py +++ b/scripts/verify_included_modules.py @@ -27,7 +27,6 @@ BASE_DIR = os.path.abspath( os.path.join(os.path.dirname(__file__), '..')) DOCS_DIR = os.path.join(BASE_DIR, 'docs') -OBJECT_INVENTORY_RELPATH = os.path.join('_build', 'html', 'objects.inv') IGNORED_PREFIXES = ('test_', '_') IGNORED_MODULES = frozenset([ 'gcloud.__init__', @@ -118,11 +117,18 @@ def get_public_modules(path, base_package=None): return result -def main(): - """Main script to verify modules included.""" +def main(build_root='_build'): + """Main script to verify modules included. + + :type build_root: str + :param build_root: The root of the directory where docs are built into. + Defaults to ``_build``. + """ + object_inventory_relpath = os.path.join(build_root, 'html', 'objects.inv') + mock_uri = '' inventory = fetch_inventory(SphinxApp, mock_uri, - OBJECT_INVENTORY_RELPATH) + object_inventory_relpath) sphinx_mods = set(inventory['py:module'].keys()) library_dir = os.path.join(BASE_DIR, 'gcloud') @@ -150,4 +156,5 @@ def main(): if __name__ == '__main__': - main() + _, build_root = sys.argv + main(build_root=build_root) diff --git a/tox.ini b/tox.ini index 5ab517d3dd33d..1d9d5a6fa8469 100644 --- a/tox.ini +++ b/tox.ini @@ -70,7 +70,7 @@ basepython = commands = python -c "import shutil; shutil.rmtree('docs/_build', ignore_errors=True)" sphinx-build -W -b html -d docs/_build/doctrees docs docs/_build/html - python {toxinidir}/scripts/verify_included_modules.py + python {toxinidir}/scripts/verify_included_modules.py _build deps = {[testenv]deps} {[docs]deps} @@ -99,7 +99,7 @@ basepython = {[testenv:docs]basepython} commands = python -c "import shutil; shutil.rmtree('docs/_build_rtd', ignore_errors=True)" sphinx-build -W -b html -d docs/_build_rtd/doctrees docs docs/_build_rtd/html - python {toxinidir}/scripts/verify_included_modules.py + python {toxinidir}/scripts/verify_included_modules.py _build_rtd deps = {[testing]deps} {[docs]deps}