Don't load extensions by default tho heh

This commit is contained in:
Jeff Forcier 2018-06-20 12:54:29 -07:00
parent 4167f38f7b
commit 87724860a6

View file

@ -197,7 +197,7 @@ def make_app(**kwargs):
in one's own test output and/or debug logs. in one's own test output and/or debug logs.
Finally, it does load the given srcdir's ``conf.py``, but only to read Finally, it does load the given srcdir's ``conf.py``, but only to read
specific bits like ``extensions``; most of it is ignored. specific bits like ``extensions`` (if requested); most of it is ignored.
All args are stored in a single ``**kwargs``. Aside from the params listed All args are stored in a single ``**kwargs``. Aside from the params listed
below (all of which are optional), all kwargs given are turned into below (all of which are optional), all kwargs given are turned into
@ -216,11 +216,17 @@ def make_app(**kwargs):
:param str doctreedir: :param str doctreedir:
Sphinx doctree directory path. Sphinx doctree directory path.
:param bool load_extensions:
Whether to load the real ``conf.py`` and setup any extensions it
configures. Default: ``False``.
:returns: A Sphinx ``Application`` instance. :returns: A Sphinx ``Application`` instance.
""" """
srcdir = kwargs.pop('srcdir', mkdtemp()) srcdir = kwargs.pop('srcdir', mkdtemp())
dstdir = kwargs.pop('dstdir', mkdtemp()) dstdir = kwargs.pop('dstdir', mkdtemp())
doctreedir = kwargs.pop('doctreedir', mkdtemp()) doctreedir = kwargs.pop('doctreedir', mkdtemp())
load_extensions = kwargs.pop('load_extensions', False)
real_conf = None
try: try:
# Sphinx <1.6ish # Sphinx <1.6ish
Sphinx._log = lambda self, message, wfile, nonl=False: None Sphinx._log = lambda self, message, wfile, nonl=False: None
@ -236,7 +242,8 @@ def make_app(**kwargs):
buildername='html', buildername='html',
) )
# Might as well load the conf file here too. # Might as well load the conf file here too.
real_conf = load_conf(srcdir) if load_extensions:
real_conf = load_conf(srcdir)
finally: finally:
for d in (srcdir, dstdir, doctreedir): for d in (srcdir, dstdir, doctreedir):
# Only remove empty dirs; non-empty dirs are implicitly something # Only remove empty dirs; non-empty dirs are implicitly something
@ -273,11 +280,12 @@ def make_app(**kwargs):
app.config.init_values(lambda x: x) app.config.init_values(lambda x: x)
# Initialize extensions (the internal call to this happens at init time, # Initialize extensions (the internal call to this happens at init time,
# which of course had no valid config yet here...) # which of course had no valid config yet here...)
for extension in real_conf['extensions']: if load_extensions:
# But don't set up ourselves again, that's bad... for extension in real_conf['extensions']:
if extension == 'releases': # But don't set up ourselves again, that causes errors
continue if extension == 'releases':
app.setup_extension(extension) continue
app.setup_extension(extension)
return app return app