From 8bc8f208d0c8e51e09902211f2fbc07cb6861490 Mon Sep 17 00:00:00 2001 From: John Kirkham Date: Fri, 3 Aug 2018 17:34:38 -0400 Subject: [PATCH] Add a fix for ReadTheDocs Adjust how `sphinx-apidoc` is run from `conf.py` to handle incompatibilities between Sphinx pre-1.7 and post-1.7. --- docs/conf.py | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 5808494..d54a19c 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -280,27 +280,30 @@ #texinfo_no_detailmenu = False -# Run sphinx-apidoc before building docs. def run_apidoc(_): - import sphinx.apidoc - ignore_paths = [ - "../setup.py", - "../tests", - "../travis_pypi_setup.py", - "../versioneer.py" + ... ] - sphinx.apidoc.main( - [ - sphinx.apidoc.__file__, - "-f", - "-T", - "-e", - "-M", - "-o", ".", - ".." - ] + ignore_paths - ) + + argv = [ + "-f", + "-T", + "-e", + "-M", + "-o", ".", + ".." + ] + ignore_paths + + try: + # Sphinx 1.7+ + from sphinx.ext import apidoc + except ImportError: + # Sphinx 1.6 (and earlier) + from sphinx import apidoc + argv.insert(0, apidoc.__file__) + + apidoc.main(argv) + def setup(app): app.connect('builder-inited', run_apidoc)