|
66 | 66 |
|
67 | 67 |
|
68 | 68 | 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 | +
|
71 | 71 | The role ``xref_param_type`` *may be* added to any token |
72 | 72 | that looks like type information and no other. The |
73 | 73 | function tries to be clever and catch type information |
@@ -165,21 +165,25 @@ def xref_param_type_role(role, rawtext, text, lineno, inliner, |
165 | 165 | Add a pending_xref for the param_type of a field list |
166 | 166 | """ |
167 | 167 | has_title, title, target = split_explicit_title(text) |
| 168 | + env = inliner.document.settings.env |
168 | 169 | if has_title: |
169 | 170 | target = target.lstrip('~') |
170 | 171 | else: |
171 | 172 | if target.startswith(('~', '.')): |
172 | 173 | prefix, target = target[0], target[1:] |
173 | 174 | if prefix == '.': |
174 | | - env = inliner.document.settings.env |
175 | 175 | modname = env.ref_context.get('py:module') |
176 | 176 | target = target[1:] |
177 | 177 | target = '%s.%s' % (modname, target) |
178 | 178 | elif prefix == '~': |
179 | 179 | title = target.split('.')[-1] |
180 | 180 |
|
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