mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
#196: Add a warning if an extension module doesn't have a `setup()
` function.
This commit is contained in:
parent
f45aeb4b05
commit
5e439cbbb5
3
CHANGES
3
CHANGES
@ -1,6 +1,9 @@
|
|||||||
Release 0.6.2 (in development)
|
Release 0.6.2 (in development)
|
||||||
==============================
|
==============================
|
||||||
|
|
||||||
|
* #196: Add a warning if an extension module doesn't have a
|
||||||
|
``setup()`` function.
|
||||||
|
|
||||||
* #158: Allow '..' in template names, and absolute template paths;
|
* #158: Allow '..' in template names, and absolute template paths;
|
||||||
Jinja 2 by default disables both.
|
Jinja 2 by default disables both.
|
||||||
|
|
||||||
|
@ -167,7 +167,10 @@ class Sphinx(object):
|
|||||||
except ImportError, err:
|
except ImportError, err:
|
||||||
raise ExtensionError('Could not import extension %s' % extension,
|
raise ExtensionError('Could not import extension %s' % extension,
|
||||||
err)
|
err)
|
||||||
if hasattr(mod, 'setup'):
|
if not hasattr(mod, 'setup'):
|
||||||
|
self.warn('extension %r has no setup() function; is it really '
|
||||||
|
'a Sphinx extension module?' % extension)
|
||||||
|
else:
|
||||||
mod.setup(self)
|
mod.setup(self)
|
||||||
self._extensions[extension] = mod
|
self._extensions[extension] = mod
|
||||||
|
|
||||||
|
@ -57,3 +57,13 @@ def test_output():
|
|||||||
assert app._warncount == old_count + 1
|
assert app._warncount == old_count + 1
|
||||||
finally:
|
finally:
|
||||||
app.cleanup()
|
app.cleanup()
|
||||||
|
|
||||||
|
|
||||||
|
def test_extensions():
|
||||||
|
status, warnings = StringIO(), StringIO()
|
||||||
|
app = TestApp(status=status, warning=warnings)
|
||||||
|
try:
|
||||||
|
app.setup_extension('shutil')
|
||||||
|
assert warnings.getvalue().startswith("WARNING: extension 'shutil'")
|
||||||
|
finally:
|
||||||
|
app.cleanup()
|
||||||
|
Loading…
Reference in New Issue
Block a user