Skip to content

Commit

Permalink
Merge pull request #2174 from dhermes/fix-docs-rtd
Browse files Browse the repository at this point in the history
Fixing docs-rtd tox rule.
  • Loading branch information
dhermes committed Aug 25, 2016
2 parents e5a1de9 + 7b90ada commit 2a0586f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
32 changes: 27 additions & 5 deletions scripts/verify_included_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

from __future__ import print_function

import argparse
import os
import sys
import warnings
Expand All @@ -27,7 +28,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__',
Expand Down Expand Up @@ -118,11 +118,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')
Expand All @@ -149,5 +156,20 @@ def main():
sys.exit(1)


def get_parser():
"""Get simple ``argparse`` parser to determine package.
:rtype: :class:`argparse.ArgumentParser`
:returns: The parser for this script.
"""
parser = argparse.ArgumentParser(
description='Run check that all GCloud modules are included in docs.')
parser.add_argument('--build-root', dest='build_root',
help='The root directory where docs are located.')
return parser


if __name__ == '__main__':
main()
parser = get_parser()
args = parser.parse_args()
main(build_root=args.build_root)
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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-root _build
deps =
{[testenv]deps}
{[docs]deps}
Expand Down Expand Up @@ -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-root _build_rtd
deps =
{[testing]deps}
{[docs]deps}
Expand Down

0 comments on commit 2a0586f

Please sign in to comment.