Skip to content

Commit b352cd7

Browse files
authored
BUG: Connect to earlier event (#269)
2 parents 37e4f25 + 1c4a94c commit b352cd7

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

numpydoc/numpydoc.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import sphinx
2929
from sphinx.addnodes import pending_xref, desc_content
3030
from sphinx.util import logging
31+
from sphinx.errors import ExtensionError
3132

3233
if sphinx.__version__ < '1.6.5':
3334
raise RuntimeError("Sphinx 1.6.5 or newer is required")
@@ -231,7 +232,13 @@ def setup(app, get_doc_object_=get_doc_object):
231232

232233
app.setup_extension('sphinx.ext.autosummary')
233234

234-
app.connect('builder-inited', update_config)
235+
# Once we bump our Sphinx requirement higher (1.7 or 1.8?)
236+
# we can just connect to config-inited
237+
try:
238+
app.connect('config-inited', update_config)
239+
except ExtensionError:
240+
app.connect('builder-inited', update_config)
241+
235242
app.connect('autodoc-process-docstring', mangle_docstrings)
236243
app.connect('autodoc-process-signature', mangle_signature)
237244
app.connect('doctree-read', relabel_references)
@@ -257,17 +264,19 @@ def setup(app, get_doc_object_=get_doc_object):
257264
return metadata
258265

259266

260-
def update_config(app):
267+
def update_config(app, config=None):
261268
"""Update the configuration with default values."""
269+
if config is None: # needed for testing and old Sphinx
270+
config = app.config
262271
# Do not simply overwrite the `app.config.numpydoc_xref_aliases`
263272
# otherwise the next sphinx-build will compare the incoming values (without
264273
# our additions) to the old values (with our additions) and trigger
265274
# a full rebuild!
266-
numpydoc_xref_aliases_complete = deepcopy(app.config.numpydoc_xref_aliases)
275+
numpydoc_xref_aliases_complete = deepcopy(config.numpydoc_xref_aliases)
267276
for key, value in DEFAULT_LINKS.items():
268277
if key not in numpydoc_xref_aliases_complete:
269278
numpydoc_xref_aliases_complete[key] = value
270-
app.config.numpydoc_xref_aliases_complete = numpydoc_xref_aliases_complete
279+
config.numpydoc_xref_aliases_complete = numpydoc_xref_aliases_complete
271280

272281

273282
# ------------------------------------------------------------------------------

0 commit comments

Comments
 (0)