Skip to content

Commit

Permalink
Adjust Sphinx arg handling for 1.7.0+ (#4)
Browse files Browse the repository at this point in the history
As of 1.7.0+, the first argument to `sphinx.apidoc.main` need not be the
executable. So this checks the version of `sphinx` in use to make sure
the executable path is only included on older versions of Sphinx.
  • Loading branch information
jakirkham committed Apr 15, 2018
1 parent 3d68897 commit dfbca47
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import sys
import os
from distutils.version import StrictVersion

# If extensions (or modules to document with autodoc) are in another
# directory, add these directories to sys.path here. If the directory is
Expand Down Expand Up @@ -282,6 +283,7 @@

# Run sphinx-apidoc before building docs.
def run_apidoc(_):
import sphinx
import sphinx.apidoc

ignore_paths = [
Expand All @@ -290,17 +292,25 @@ def run_apidoc(_):
"../travis_pypi_setup.py",
"../versioneer.py"
]
sphinx.apidoc.main(

sphinx_apidoc_args = []
if StrictVersion(sphinx.__version__) < StrictVersion("1.7.0"):
sphinx_apidoc_args.append(sphinx.apidoc.__file__)

sphinx_apidoc_args.extend(
[
sphinx.apidoc.__file__,
"-f",
"-T",
"-e",
"-M",
"-o", ".",
".."
] + ignore_paths
]
)

sphinx_apidoc_args.extend(ignore_paths)

sphinx.apidoc.main(sphinx_apidoc_args)

def setup(app):
app.connect('builder-inited', run_apidoc)

0 comments on commit dfbca47

Please sign in to comment.