Skip to content

Commit 2a0586f

Browse files
authored
Merge pull request #2174 from dhermes/fix-docs-rtd
Fixing docs-rtd tox rule.
2 parents e5a1de9 + 7b90ada commit 2a0586f

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

scripts/verify_included_modules.py

+27-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
from __future__ import print_function
1919

20+
import argparse
2021
import os
2122
import sys
2223
import warnings
@@ -27,7 +28,6 @@
2728
BASE_DIR = os.path.abspath(
2829
os.path.join(os.path.dirname(__file__), '..'))
2930
DOCS_DIR = os.path.join(BASE_DIR, 'docs')
30-
OBJECT_INVENTORY_RELPATH = os.path.join('_build', 'html', 'objects.inv')
3131
IGNORED_PREFIXES = ('test_', '_')
3232
IGNORED_MODULES = frozenset([
3333
'gcloud.__init__',
@@ -118,11 +118,18 @@ def get_public_modules(path, base_package=None):
118118
return result
119119

120120

121-
def main():
122-
"""Main script to verify modules included."""
121+
def main(build_root='_build'):
122+
"""Main script to verify modules included.
123+
124+
:type build_root: str
125+
:param build_root: The root of the directory where docs are built into.
126+
Defaults to ``_build``.
127+
"""
128+
object_inventory_relpath = os.path.join(build_root, 'html', 'objects.inv')
129+
123130
mock_uri = ''
124131
inventory = fetch_inventory(SphinxApp, mock_uri,
125-
OBJECT_INVENTORY_RELPATH)
132+
object_inventory_relpath)
126133
sphinx_mods = set(inventory['py:module'].keys())
127134

128135
library_dir = os.path.join(BASE_DIR, 'gcloud')
@@ -149,5 +156,20 @@ def main():
149156
sys.exit(1)
150157

151158

159+
def get_parser():
160+
"""Get simple ``argparse`` parser to determine package.
161+
162+
:rtype: :class:`argparse.ArgumentParser`
163+
:returns: The parser for this script.
164+
"""
165+
parser = argparse.ArgumentParser(
166+
description='Run check that all GCloud modules are included in docs.')
167+
parser.add_argument('--build-root', dest='build_root',
168+
help='The root directory where docs are located.')
169+
return parser
170+
171+
152172
if __name__ == '__main__':
153-
main()
173+
parser = get_parser()
174+
args = parser.parse_args()
175+
main(build_root=args.build_root)

tox.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ basepython =
7070
commands =
7171
python -c "import shutil; shutil.rmtree('docs/_build', ignore_errors=True)"
7272
sphinx-build -W -b html -d docs/_build/doctrees docs docs/_build/html
73-
python {toxinidir}/scripts/verify_included_modules.py
73+
python {toxinidir}/scripts/verify_included_modules.py --build-root _build
7474
deps =
7575
{[testenv]deps}
7676
{[docs]deps}
@@ -99,7 +99,7 @@ basepython = {[testenv:docs]basepython}
9999
commands =
100100
python -c "import shutil; shutil.rmtree('docs/_build_rtd', ignore_errors=True)"
101101
sphinx-build -W -b html -d docs/_build_rtd/doctrees docs docs/_build_rtd/html
102-
python {toxinidir}/scripts/verify_included_modules.py
102+
python {toxinidir}/scripts/verify_included_modules.py --build-root _build_rtd
103103
deps =
104104
{[testing]deps}
105105
{[docs]deps}

0 commit comments

Comments
 (0)