37
37
raise RuntimeError ("Sphinx 1.0.1 or newer is required" )
38
38
39
39
from .docscrape_sphinx import get_doc_object
40
+ from .xref import DEFAULT_LINKS
40
41
from . import __version__
41
42
42
43
if sys .version_info [0 ] >= 3 :
@@ -154,7 +155,11 @@ def mangle_docstrings(app, what, name, obj, options, lines):
154
155
app .config .numpydoc_show_inherited_class_members ,
155
156
'class_members_toctree' : app .config .numpydoc_class_members_toctree ,
156
157
'attributes_as_param_list' :
157
- app .config .numpydoc_attributes_as_param_list }
158
+ app .config .numpydoc_attributes_as_param_list ,
159
+ 'xref_param_type' : app .config .numpydoc_xref_param_type ,
160
+ 'xref_aliases' : app .config .numpydoc_xref_aliases ,
161
+ 'xref_ignore' : app .config .numpydoc_xref_ignore ,
162
+ }
158
163
159
164
cfg .update (options or {})
160
165
u_NL = sixu ('\n ' )
@@ -218,6 +223,7 @@ def setup(app, get_doc_object_=get_doc_object):
218
223
219
224
app .setup_extension ('sphinx.ext.autosummary' )
220
225
226
+ app .connect ('builder-inited' , update_config )
221
227
app .connect ('autodoc-process-docstring' , mangle_docstrings )
222
228
app .connect ('autodoc-process-signature' , mangle_signature )
223
229
app .connect ('doctree-read' , relabel_references )
@@ -230,6 +236,9 @@ def setup(app, get_doc_object_=get_doc_object):
230
236
app .add_config_value ('numpydoc_class_members_toctree' , True , True )
231
237
app .add_config_value ('numpydoc_citation_re' , '[a-z0-9_.-]+' , True )
232
238
app .add_config_value ('numpydoc_attributes_as_param_list' , True , True )
239
+ app .add_config_value ('numpydoc_xref_param_type' , False , True )
240
+ app .add_config_value ('numpydoc_xref_aliases' , dict (), True )
241
+ app .add_config_value ('numpydoc_xref_ignore' , set (), True )
233
242
234
243
# Extra mangling domains
235
244
app .add_domain (NumpyPythonDomain )
@@ -239,6 +248,14 @@ def setup(app, get_doc_object_=get_doc_object):
239
248
'parallel_read_safe' : True }
240
249
return metadata
241
250
251
+
252
+ def update_config (app ):
253
+ """Update the configuration with default values."""
254
+ for key , value in DEFAULT_LINKS .items ():
255
+ if key not in app .config .numpydoc_xref_aliases :
256
+ app .config .numpydoc_xref_aliases [key ] = value
257
+
258
+
242
259
# ------------------------------------------------------------------------------
243
260
# Docstring-mangling domains
244
261
# ------------------------------------------------------------------------------
0 commit comments