Skip to content

Commit bd40a0d

Browse files
committed
Add config value to control behavior
1 parent e8f237e commit bd40a0d

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

numpydoc/docscrape_sphinx.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def load_config(self, config):
3030
self.xref_param_type = config.get('xref_param_type', False)
3131
self.xref_aliases = config.get('xref_aliases', dict())
3232
self.xref_ignore = config.get('xref_ignore', set())
33+
self.xref_wrap_all = config.get('xref_wrap_all', True)
3334
self.template = config.get('template', None)
3435
if self.template is None:
3536
template_dirs = [os.path.join(os.path.dirname(__file__), 'templates')]
@@ -77,7 +78,9 @@ def _str_returns(self, name='Returns'):
7778
param_type = make_xref(
7879
param_type,
7980
self.xref_aliases,
80-
self.xref_ignore)
81+
self.xref_ignore,
82+
self.xref_wrap_all
83+
)
8184
if param.name:
8285
out += self._str_indent([named_fmt % (param.name.strip(),
8386
param_type)])
@@ -217,7 +220,9 @@ def _str_param_list(self, name, fake_autosummary=False):
217220
param_type = make_xref(
218221
param_type,
219222
self.xref_aliases,
220-
self.xref_ignore)
223+
self.xref_ignore,
224+
self.xref_wrap_all
225+
)
221226
parts.append(param_type)
222227
out += self._str_indent([' : '.join(parts)])
223228

numpydoc/numpydoc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ def mangle_docstrings(app, what, name, obj, options, lines):
155155
'xref_param_type': app.config.numpydoc_xref_param_type,
156156
'xref_aliases': app.config.numpydoc_xref_aliases_complete,
157157
'xref_ignore': app.config.numpydoc_xref_ignore,
158+
'xref_wrap_all': app.config.numpydoc_xref_wrap_all,
158159
}
159160

160161
cfg.update(options or {})
@@ -254,6 +255,7 @@ def setup(app, get_doc_object_=get_doc_object):
254255
app.add_config_value('numpydoc_xref_param_type', False, True)
255256
app.add_config_value('numpydoc_xref_aliases', dict(), True)
256257
app.add_config_value('numpydoc_xref_ignore', set(), True)
258+
app.add_config_value('numpydoc_xref_wrap_all', True, True)
257259

258260
# Extra mangling domains
259261
app.add_domain(NumpyPythonDomain)

numpydoc/tests/test_numpydoc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class MockConfig():
1515
numpydoc_xref_aliases = {}
1616
numpydoc_xref_aliases_complete = deepcopy(DEFAULT_LINKS)
1717
numpydoc_xref_ignore = set()
18+
numpydoc_xref_wrap_all = True
1819
templates_path = []
1920
numpydoc_edit_link = False
2021
numpydoc_citation_re = '[a-z0-9_.-]+'

0 commit comments

Comments
 (0)