summaryrefslogtreecommitdiff
path: root/pbr
diff options
context:
space:
mode:
authorDoug Hellmann <doug@doughellmann.com>2018-01-17 14:42:48 -0500
committerDoug Hellmann <doug@doughellmann.com>2018-01-17 15:34:07 -0500
commit8aaf237382848dd2de370392cdb11c5f218a370e (patch)
tree5a469c6027803313c225b343a3dfe0b75922e677 /pbr
parentea3e5ab4037fd9e570d0dd402712f7f2cf55905b (diff)
downloadpbr-8aaf237382848dd2de370392cdb11c5f218a370e.tar.gz
future-proof invocation of apidoc
Newer versions of Sphinx have moved the apidoc module into sphinx.ext and the API is slightly different (the function expects sys.argv[1:] instead of sys.argv[:]. So, figure out where we can import it from and set a flag so we can invoke it properly. See this change in sphinx for details: https://github.com/sphinx-doc/sphinx/commit/87630c8ae8bff8c0e23187676e6343d8903003a6 Change-Id: I8235968f8a474c9e6088d935d0868570b2917c07 Signed-off-by: Doug Hellmann <doug@doughellmann.com>
Diffstat (limited to 'pbr')
-rw-r--r--pbr/builddoc.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/pbr/builddoc.py b/pbr/builddoc.py
index cd75792..9f61920 100644
--- a/pbr/builddoc.py
+++ b/pbr/builddoc.py
@@ -26,7 +26,18 @@ except ImportError:
try:
import sphinx
- from sphinx import apidoc
+ # NOTE(dhellmann): Newer versions of Sphinx have moved the apidoc
+ # module into sphinx.ext and the API is slightly different (the
+ # function expects sys.argv[1:] instead of sys.argv[:]. So, figure
+ # out where we can import it from and set a flag so we can invoke
+ # it properly. See this change in sphinx for details:
+ # https://github.com/sphinx-doc/sphinx/commit/87630c8ae8bff8c0e23187676e6343d8903003a6
+ try:
+ from sphinx.ext import apidoc
+ apidoc_use_padding = False
+ except ImportError:
+ from sphinx import apidoc
+ apidoc_use_padding = True
from sphinx import application
from sphinx import setup_command
except Exception as e:
@@ -119,7 +130,9 @@ class LocalBuildDoc(setup_command.BuildDoc):
def _sphinx_tree(self):
source_dir = self._get_source_dir()
- cmd = ['apidoc', '.', '-H', 'Modules', '-o', source_dir]
+ cmd = ['-H', 'Modules', '-o', source_dir, '.']
+ if apidoc_use_padding:
+ cmd.insert(0, 'apidoc')
apidoc.main(cmd + self.autodoc_tree_excludes)
def _sphinx_run(self):