summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2017-01-12 23:42:56 +0900
committerGitHub <noreply@github.com>2017-01-12 23:42:56 +0900
commit81a4248df90be6075aba8fa65dd1cd13b67fd3d4 (patch)
tree1b0819f144ea07a473ce2f6ced6a6c0af94a6d5b
parent3060456dbcf3af1c67a8c6a215efccd0c9c30bcc (diff)
parenta2cddfeac990b0ab472b304f86a8986ec41c9019 (diff)
downloadsphinx-git-81a4248df90be6075aba8fa65dd1cd13b67fd3d4.tar.gz
Merge pull request #3323 from gbaier/apidoc_extensions
apidoc takes extension options
-rw-r--r--sphinx/apidoc.py10
-rw-r--r--tests/test_apidoc.py13
2 files changed, 23 insertions, 0 deletions
diff --git a/sphinx/apidoc.py b/sphinx/apidoc.py
index 0fca17d81..11d2994ef 100644
--- a/sphinx/apidoc.py
+++ b/sphinx/apidoc.py
@@ -25,6 +25,7 @@ from fnmatch import fnmatch
from sphinx.util.osutil import FileAvoidWrite, walk
from sphinx import __display_version__
+from sphinx.quickstart import EXTENSIONS
if False:
# For type annotation
@@ -346,6 +347,11 @@ Note: By default this script will not overwrite already created files.""")
'defaults to --doc-version')
parser.add_option('--version', action='store_true', dest='show_version',
help='Show version information and exit')
+ group = parser.add_option_group('Extension options')
+ for ext in EXTENSIONS:
+ group.add_option('--ext-' + ext, action='store_true',
+ dest='ext_' + ext, default=False,
+ help='enable %s extension' % ext)
(opts, args) = parser.parse_args(argv[1:])
@@ -404,6 +410,10 @@ Note: By default this script will not overwrite already created files.""")
module_path = rootpath,
append_syspath = opts.append_syspath,
)
+ enabled_exts = {'ext_' + ext: getattr(opts, 'ext_' + ext)
+ for ext in EXTENSIONS if getattr(opts, 'ext_' + ext)}
+ d.update(enabled_exts)
+
if isinstance(opts.header, binary_type):
d['project'] = d['project'].decode('utf-8')
if isinstance(opts.author, binary_type):
diff --git a/tests/test_apidoc.py b/tests/test_apidoc.py
index d44868aeb..7e6c4fd0a 100644
--- a/tests/test_apidoc.py
+++ b/tests/test_apidoc.py
@@ -145,3 +145,16 @@ def test_multibyte_parameters(make_app, apidoc):
app.build()
print(app._status.getvalue())
print(app._warning.getvalue())
+
+
+@pytest.mark.apidoc(
+ coderoot=(rootdir / 'root'),
+ options=['--ext-mathjax'],
+)
+def test_extension_parsed(make_app, apidoc):
+ outdir = apidoc.outdir
+ assert (outdir / 'conf.py').isfile()
+
+ with open(outdir / 'conf.py') as f:
+ rst = f.read()
+ assert "sphinx.ext.mathjax" in rst