Skip to content

Commit bf4eb04

Browse files
committed
FIX: Uniform styling
1 parent 54ca079 commit bf4eb04

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

doc/install.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ numpydoc_xref_param_type : bool
4747
``Parameters``, ``Other Parameters``, ``Returns`` and ``Yields``
4848
sections of the docstring.
4949
``False`` by default.
50+
51+
.. note:: Depending on the link types, the CSS styles might be different.
52+
consider overridding e.g. ``span.classifier span.xref a`` and
53+
``span.classifier code.docutils.literal.notranslate, a``
54+
CSS classes to achieve a uniform appearance.
55+
5056
numpydoc_xref_aliases : dict
5157
Mappings to fully qualified paths (or correct ReST references) for the
5258
aliases/shortcuts used when specifying the types of parameters.

numpydoc/xref.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@
6666

6767

6868
def make_xref_param_type(param_type, xref_aliases, xref_ignore):
69-
"""
70-
Enclose str in a role that creates a cross-reference
69+
"""Enclose str in a role that creates a cross-reference.
70+
7171
The role ``xref_param_type`` *may be* added to any token
7272
that looks like type information and no other. The
7373
function tries to be clever and catch type information
@@ -165,21 +165,25 @@ def xref_param_type_role(role, rawtext, text, lineno, inliner,
165165
Add a pending_xref for the param_type of a field list
166166
"""
167167
has_title, title, target = split_explicit_title(text)
168+
env = inliner.document.settings.env
168169
if has_title:
169170
target = target.lstrip('~')
170171
else:
171172
if target.startswith(('~', '.')):
172173
prefix, target = target[0], target[1:]
173174
if prefix == '.':
174-
env = inliner.document.settings.env
175175
modname = env.ref_context.get('py:module')
176176
target = target[1:]
177177
target = '%s.%s' % (modname, target)
178178
elif prefix == '~':
179179
title = target.split('.')[-1]
180180

181-
contnode = nodes.Text(title, title)
182-
node = addnodes.pending_xref('', refdomain='py', refexplicit=False,
183-
reftype='class', reftarget=target)
184-
node += contnode
185-
return [node], []
181+
domain = 'py'
182+
contnode = nodes.literal(title, title)
183+
refnode = addnodes.pending_xref('', refdomain=domain, refexplicit=False,
184+
reftype='class', reftarget=target)
185+
refnode += contnode
186+
# attach information about the current scope
187+
if env:
188+
env.get_domain(domain).process_field_xref(refnode)
189+
return [refnode], []

0 commit comments

Comments
 (0)