Skip to content

Commit

Permalink
Merge pull request #345 from JWCook/sphinx-apidoc
Browse files Browse the repository at this point in the history
Use sphinxcontrib-apidoc extension for readthedocs builds
  • Loading branch information
jparise authored Aug 10, 2021
2 parents 86f6485 + 76a443c commit 0ecdc4c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 19 deletions.
1 change: 1 addition & 0 deletions docs-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
sphinx==3.0.3
sphinx_rtd_theme
sphinxcontrib-apidoc
sphinxcontrib-napoleon
22 changes: 5 additions & 17 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
'sphinx.ext.intersphinx',
'sphinx.ext.napoleon',
'sphinx.ext.ifconfig',
'sphinxcontrib.apidoc',
]

# Add any paths that contain templates here, relative to this directory.
Expand Down Expand Up @@ -350,20 +351,7 @@


# Automate building apidoc when building with readthedocs
# https://github.com/rtfd/readthedocs.org/issues/1139
def run_apidoc(_):
module = 'pymemcache'
cur_dir = os.path.abspath(os.path.dirname(__file__))
output_path = os.path.join(cur_dir, 'apidoc')
module_path = os.path.join(cur_dir, '..', module)
cmd_path = 'sphinx-apidoc'
if hasattr(sys, 'real_prefix'): # Check to see if we are in a virtualenv
# If we are, assemble the path manually
cmd_path = os.path.abspath(os.path.join(sys.prefix,
'bin', 'sphinx-apidoc'))
subprocess.check_call([cmd_path, '-e', '-o',
output_path, module_path, '--force'])


def setup(app):
app.connect('builder-inited', run_apidoc)
apidoc_module_dir = os.path.join('..', 'pymemcache')
apidoc_output_dir = 'apidoc'
apidoc_separate_modules = True
apidoc_extra_args = ['--force']
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ commands =
[testenv:docs]
commands =
pip install -r docs-requirements.txt
sphinx-apidoc -o docs/apidoc/ pymemcache
sphinx-build -b html docs/ docs/_build
sphinx-build -b html docs/ docs/_build/html

[testenv:venv]
commands = {posargs}

0 comments on commit 0ecdc4c

Please sign in to comment.