Skip to content

Commit

Permalink
[Docs] Move apidoc command to Sphinx config
Browse files Browse the repository at this point in the history
The apidoc modules were not being generated on ReadTheDocs because
there is no way to run sphinx-apidoc manually.

Moved the running of sphinx-apidoc into conf.py.

Added zope.interface minimum version to fix Readthedocs warning.
  • Loading branch information
cas-- committed Nov 2, 2018
1 parent 20431cc commit 98051bd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
20 changes: 20 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import pkg_resources
from recommonmark.states import DummyStateMachine
from recommonmark.transform import AutoStructify
from sphinx.ext import apidoc
from sphinx.ext.autodoc import ClassDocumenter, bool_option

try:
Expand Down Expand Up @@ -297,7 +298,26 @@ def maybe_skip_member(app, what, name, obj, skip, options):
return True


# Run the sphinx-apidoc to create package/modules rst files for autodoc.
def run_apidoc(__):
cur_dir = os.path.abspath(os.path.dirname(__file__))
module_dir = os.path.join(cur_dir, '..', '..', 'deluge')
ignore_paths = [
os.path.join(module_dir, 'plugins'),
os.path.join(module_dir, 'tests'),
]
argv = [
'--force',
'--no-toc',
'--output-dir',
os.path.join(cur_dir, 'modules'),
module_dir,
] + ignore_paths
apidoc.main(argv)


def setup(app):
app.connect('builder-inited', run_apidoc)
app.connect('autodoc-skip-member', maybe_skip_member)
app.add_config_value('recommonmark_config', {}, True)
app.add_transform(AutoStructify)
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ setproctitle
pywin32; sys.platform == 'win32'
py2-ipaddress; sys.platform == 'win32'
certifi; sys.platform == 'win32'
zope.interface
zope.interface>=4.4.2
14 changes: 1 addition & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,6 @@ def run_tests(self):
sys.exit(errcode)


class BuildDocs(BuildDoc):
description = 'Build the documentation'

def run(self):
print('Generating module documentation...')
os.system(
'sphinx-apidoc --force --no-toc'
' -o docs/source/modules/ deluge deluge/plugins'
)
BuildDoc.run(self)


class CleanDocs(cmd.Command):
description = 'Clean the documentation build and module rst files'
user_options = []
Expand Down Expand Up @@ -454,7 +442,7 @@ def run(self):
'build_webui': BuildWebUI,
'build_trans': BuildTranslations,
'build_plugins': BuildPlugins,
'build_docs': BuildDocs,
'build_docs': BuildDoc,
'install_data': InstallData,
'clean_plugins': CleanPlugins,
'clean_trans': CleanTranslations,
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ skip_install = True
deps = {[docsbase]deps}
commands =
python setup.py clean_docs
sphinx-apidoc --force --no-toc -o docs/source/modules/ deluge deluge/plugins
sphinx-build -v -j auto -E -T -b html -d docs/build/doctrees docs/source docs/build/html

[testenv:docscoverage]
Expand Down

0 comments on commit 98051bd

Please sign in to comment.