diff options
author | Joel Nothman <joel.nothman@gmail.com> | 2020-06-27 21:33:30 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-27 21:33:30 +1000 |
commit | b352cd7635f2ea7748722f410a31f937d92545cc (patch) | |
tree | 49c23768ca58d142afd6e167c17fb1dc5621cf8b | |
parent | 37e4f25a0ba2685f17901fad493be25268deeac7 (diff) | |
parent | 1c4a94c525a4665dde4580c11beade03ddcc2128 (diff) | |
download | numpydoc-b352cd7635f2ea7748722f410a31f937d92545cc.tar.gz |
BUG: Connect to earlier event (#269)
-rw-r--r-- | numpydoc/numpydoc.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/numpydoc/numpydoc.py b/numpydoc/numpydoc.py index 7a77d55..93cd975 100644 --- a/numpydoc/numpydoc.py +++ b/numpydoc/numpydoc.py @@ -28,6 +28,7 @@ from docutils.nodes import citation, Text, section, comment, reference import sphinx from sphinx.addnodes import pending_xref, desc_content from sphinx.util import logging +from sphinx.errors import ExtensionError if sphinx.__version__ < '1.6.5': raise RuntimeError("Sphinx 1.6.5 or newer is required") @@ -231,7 +232,13 @@ def setup(app, get_doc_object_=get_doc_object): app.setup_extension('sphinx.ext.autosummary') - app.connect('builder-inited', update_config) + # Once we bump our Sphinx requirement higher (1.7 or 1.8?) + # we can just connect to config-inited + try: + app.connect('config-inited', update_config) + except ExtensionError: + app.connect('builder-inited', update_config) + app.connect('autodoc-process-docstring', mangle_docstrings) app.connect('autodoc-process-signature', mangle_signature) app.connect('doctree-read', relabel_references) @@ -257,17 +264,19 @@ def setup(app, get_doc_object_=get_doc_object): return metadata -def update_config(app): +def update_config(app, config=None): """Update the configuration with default values.""" + if config is None: # needed for testing and old Sphinx + config = app.config # Do not simply overwrite the `app.config.numpydoc_xref_aliases` # otherwise the next sphinx-build will compare the incoming values (without # our additions) to the old values (with our additions) and trigger # a full rebuild! - numpydoc_xref_aliases_complete = deepcopy(app.config.numpydoc_xref_aliases) + numpydoc_xref_aliases_complete = deepcopy(config.numpydoc_xref_aliases) for key, value in DEFAULT_LINKS.items(): if key not in numpydoc_xref_aliases_complete: numpydoc_xref_aliases_complete[key] = value - app.config.numpydoc_xref_aliases_complete = numpydoc_xref_aliases_complete + config.numpydoc_xref_aliases_complete = numpydoc_xref_aliases_complete # ------------------------------------------------------------------------------ |