apidoc takes extension options

This commit is contained in:
Gerald Baier 2017-01-11 11:23:34 +01:00
parent de3d03a7b5
commit 2402fd7ebe
2 changed files with 28 additions and 0 deletions

View File

@ -346,6 +346,12 @@ 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')
from sphinx.quickstart import EXTENSIONS
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):

View File

@ -145,3 +145,21 @@ 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
app = make_app('text', srcdir=outdir)
app.build()
print(app._status.getvalue())
print(app._warning.getvalue())