|
28 | 28 | import sphinx |
29 | 29 | from sphinx.addnodes import pending_xref, desc_content |
30 | 30 | from sphinx.util import logging |
| 31 | +from sphinx.errors import ExtensionError |
31 | 32 |
|
32 | 33 | if sphinx.__version__ < '1.6.5': |
33 | 34 | raise RuntimeError("Sphinx 1.6.5 or newer is required") |
@@ -218,7 +219,13 @@ def setup(app, get_doc_object_=get_doc_object): |
218 | 219 |
|
219 | 220 | app.setup_extension('sphinx.ext.autosummary') |
220 | 221 |
|
221 | | - app.connect('config-inited', update_config) |
| 222 | + # Once we bump our Sphinx requirement higher (1.7 or 1.8?) |
| 223 | + # we can just connect to config-inited |
| 224 | + try: |
| 225 | + app.connect('config-inited', update_config) |
| 226 | + except ExtensionError: |
| 227 | + app.connect('builder-inited', update_config) |
| 228 | + |
222 | 229 | app.connect('autodoc-process-docstring', mangle_docstrings) |
223 | 230 | app.connect('autodoc-process-signature', mangle_signature) |
224 | 231 | app.connect('doctree-read', relabel_references) |
@@ -246,7 +253,7 @@ def setup(app, get_doc_object_=get_doc_object): |
246 | 253 |
|
247 | 254 | def update_config(app, config=None): |
248 | 255 | """Update the configuration with default values.""" |
249 | | - if config is None: # only really needed for testing |
| 256 | + if config is None: # needed for testing and old Sphinx |
250 | 257 | config = app.config |
251 | 258 | # Do not simply overwrite the `app.config.numpydoc_xref_aliases` |
252 | 259 | # otherwise the next sphinx-build will compare the incoming values (without |
|
0 commit comments