From 98051bdea23eefbbb4a230d63230bd29675c2356 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Fri, 2 Nov 2018 00:09:53 +0000 Subject: [PATCH] [Docs] Move apidoc command to Sphinx config 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. --- docs/source/conf.py | 20 ++++++++++++++++++++ requirements.txt | 2 +- setup.py | 14 +------------- tox.ini | 1 - 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 24bd4e368..e1a60a14a 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -18,6 +18,7 @@ from datetime import date 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: @@ -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) diff --git a/requirements.txt b/requirements.txt index 63923565a..4d1c4eb75 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/setup.py b/setup.py index b2ebf148f..df8d966a4 100755 --- a/setup.py +++ b/setup.py @@ -72,18 +72,6 @@ class PyTest(_test): 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 = [] @@ -454,7 +442,7 @@ cmdclass = { 'build_webui': BuildWebUI, 'build_trans': BuildTranslations, 'build_plugins': BuildPlugins, - 'build_docs': BuildDocs, + 'build_docs': BuildDoc, 'install_data': InstallData, 'clean_plugins': CleanPlugins, 'clean_trans': CleanTranslations, diff --git a/tox.ini b/tox.ini index ad933169b..134cde2a6 100644 --- a/tox.ini +++ b/tox.ini @@ -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]