3737 raise RuntimeError ("Sphinx 1.0.1 or newer is required" )
3838
3939from .docscrape_sphinx import get_doc_object
40+ from .xref import DEFAULT_LINKS
4041from . import __version__
4142
4243if sys .version_info [0 ] >= 3 :
@@ -154,7 +155,11 @@ def mangle_docstrings(app, what, name, obj, options, lines):
154155 app .config .numpydoc_show_inherited_class_members ,
155156 'class_members_toctree' : app .config .numpydoc_class_members_toctree ,
156157 '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+ }
158163
159164 cfg .update (options or {})
160165 u_NL = sixu ('\n ' )
@@ -218,6 +223,7 @@ def setup(app, get_doc_object_=get_doc_object):
218223
219224 app .setup_extension ('sphinx.ext.autosummary' )
220225
226+ app .connect ('builder-inited' , update_config )
221227 app .connect ('autodoc-process-docstring' , mangle_docstrings )
222228 app .connect ('autodoc-process-signature' , mangle_signature )
223229 app .connect ('doctree-read' , relabel_references )
@@ -230,6 +236,9 @@ def setup(app, get_doc_object_=get_doc_object):
230236 app .add_config_value ('numpydoc_class_members_toctree' , True , True )
231237 app .add_config_value ('numpydoc_citation_re' , '[a-z0-9_.-]+' , True )
232238 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 )
233242
234243 # Extra mangling domains
235244 app .add_domain (NumpyPythonDomain )
@@ -239,6 +248,14 @@ def setup(app, get_doc_object_=get_doc_object):
239248 'parallel_read_safe' : True }
240249 return metadata
241250
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+
242259# ------------------------------------------------------------------------------
243260# Docstring-mangling domains
244261# ------------------------------------------------------------------------------
0 commit comments