Skip to content

Commit

Permalink
Handle Sphinx changes related to apidoc location (#5)
Browse files Browse the repository at this point in the history
In Sphinx 1.7, it appears that `apidoc` was moved from `sphinx` to
`sphinx.ext`. This adopts an `ImportError` based workaround to handle
both cases. Also reverts a previous attempt to solve this issue, which
did not end up working.
  • Loading branch information
jakirkham committed Jun 18, 2018
1 parent dfbca47 commit 9982ea1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
38 changes: 17 additions & 21 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

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 @@ -283,34 +282,31 @@

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

ignore_paths = [
"../setup.py",
"../tests",
"../travis_pypi_setup.py",
"../versioneer.py"
]

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

sphinx_apidoc_args.extend(
[
"-f",
"-T",
"-e",
"-M",
"-o", ".",
".."
]
)

sphinx_apidoc_args.extend(ignore_paths)
argv = [
"-f",
"-T",
"-e",
"-M",
"-o", ".",
".."
] + ignore_paths

try:
# Sphinx-1.7+
from sphinx.ext import apidoc
apidoc.main(argv)
except ImportError:
from sphinx import apidoc
argv.insert(0, apidoc.__file__)
apidoc.main(argv)

sphinx.apidoc.main(sphinx_apidoc_args)

def setup(app):
app.connect('builder-inited', run_apidoc)
4 changes: 4 additions & 0 deletions rtd_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mock
pillow
sphinx
sphinx_rtd_theme

0 comments on commit 9982ea1

Please sign in to comment.