mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
* With non-callable setup
in a conf.py, now sphinx-build emits user-friendly error message. Closes #1499
This commit is contained in:
parent
ff8ce91f77
commit
f781f55b28
2
CHANGES
2
CHANGES
@ -15,6 +15,8 @@ Bugs fixed
|
|||||||
Thanks to Jorge_C.
|
Thanks to Jorge_C.
|
||||||
* #1467: Exception on Python3 if nonexistent method is specified by automethod
|
* #1467: Exception on Python3 if nonexistent method is specified by automethod
|
||||||
* #1441: autosummary can't handle nested classes correctly.
|
* #1441: autosummary can't handle nested classes correctly.
|
||||||
|
* #1499: With non-callable `setup` in a conf.py, now sphinx-build emits
|
||||||
|
user-friendly error message.
|
||||||
|
|
||||||
Release 1.2.2 (released Mar 2, 2014)
|
Release 1.2.2 (released Mar 2, 2014)
|
||||||
====================================
|
====================================
|
||||||
|
@ -27,7 +27,7 @@ from sphinx import package_dir, locale
|
|||||||
from sphinx.roles import XRefRole
|
from sphinx.roles import XRefRole
|
||||||
from sphinx.config import Config
|
from sphinx.config import Config
|
||||||
from sphinx.errors import SphinxError, SphinxWarning, ExtensionError, \
|
from sphinx.errors import SphinxError, SphinxWarning, ExtensionError, \
|
||||||
VersionRequirementError
|
VersionRequirementError, ConfigError
|
||||||
from sphinx.domains import ObjType, BUILTIN_DOMAINS
|
from sphinx.domains import ObjType, BUILTIN_DOMAINS
|
||||||
from sphinx.domains.std import GenericObject, Target, StandardDomain
|
from sphinx.domains.std import GenericObject, Target, StandardDomain
|
||||||
from sphinx.builders import BUILTIN_BUILDERS
|
from sphinx.builders import BUILTIN_BUILDERS
|
||||||
@ -119,7 +119,15 @@ class Sphinx(object):
|
|||||||
self.setup_extension(extension)
|
self.setup_extension(extension)
|
||||||
# the config file itself can be an extension
|
# the config file itself can be an extension
|
||||||
if self.config.setup:
|
if self.config.setup:
|
||||||
self.config.setup(self)
|
# py31 doesn't have 'callable' function for bellow check
|
||||||
|
if hasattr(self.config.setup, '__call__'):
|
||||||
|
self.config.setup(self)
|
||||||
|
else:
|
||||||
|
raise ConfigError(
|
||||||
|
"'setup' that is specified in the conf.py has not been " +
|
||||||
|
"callable. Please provide a callable `setup` function " +
|
||||||
|
"in order to behave as a sphinx extension conf.py itself."
|
||||||
|
)
|
||||||
|
|
||||||
# now that we know all config values, collect them from conf.py
|
# now that we know all config values, collect them from conf.py
|
||||||
self.config.init_values()
|
self.config.init_values()
|
||||||
|
@ -110,6 +110,13 @@ def test_errors_warnings(dir):
|
|||||||
assert warned[0]
|
assert warned[0]
|
||||||
|
|
||||||
|
|
||||||
|
@with_tempdir
|
||||||
|
def test_errors_if_setup_is_not_callable(dir):
|
||||||
|
# test the error to call setup() in the config file
|
||||||
|
(dir / 'conf.py').write_text(u'setup = 1')
|
||||||
|
raises_msg(ConfigError, 'callable', TestApp, srcdir=dir)
|
||||||
|
|
||||||
|
|
||||||
def test_needs_sphinx():
|
def test_needs_sphinx():
|
||||||
raises(VersionRequirementError, TestApp,
|
raises(VersionRequirementError, TestApp,
|
||||||
confoverrides={'needs_sphinx': '9.9'})
|
confoverrides={'needs_sphinx': '9.9'})
|
||||||
|
Loading…
Reference in New Issue
Block a user