mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Add ref context to all "any" references. Should make it possible to resolve them more accurately.
This commit is contained in:
parent
56c13b7eb8
commit
6ba8883685
@ -715,7 +715,7 @@ class PythonDomain(Domain):
|
||||
|
||||
def resolve_any_xref(self, env, fromdocname, builder, target,
|
||||
node, contnode):
|
||||
modname = node.get('py:module') # it is not likely we have these
|
||||
modname = node.get('py:module')
|
||||
clsname = node.get('py:class')
|
||||
results = []
|
||||
|
||||
|
@ -227,7 +227,7 @@ class OptionXRefRole(XRefRole):
|
||||
target = target.strip()
|
||||
elif ' ' in target:
|
||||
program, target = _split_option(target, refnode, env)
|
||||
refnode['refprogram'] = program
|
||||
refnode['std:program'] = program
|
||||
return title, target
|
||||
|
||||
|
||||
@ -608,8 +608,8 @@ class StandardDomain(Domain):
|
||||
return make_refnode(builder, fromdocname, docname,
|
||||
labelid, contnode)
|
||||
elif typ == 'option':
|
||||
if 'refprogram' in node:
|
||||
progname = node['refprogram']
|
||||
if 'std:program' in node:
|
||||
progname = node['std:program']
|
||||
elif ' -' in target or ' /' in target:
|
||||
# maybe an "any" directive, split it ourselves
|
||||
progname, target = _split_option(target, node, env)
|
||||
|
@ -164,6 +164,15 @@ class XRefRole(object):
|
||||
return [node], []
|
||||
|
||||
|
||||
class AnyXRefRole(XRefRole):
|
||||
def process_link(self, env, refnode, has_explicit_title, title, target):
|
||||
result = XRefRole.process_link(self, env, refnode, has_explicit_title,
|
||||
title, target)
|
||||
# add all possible context info (i.e. std:program, py:module etc.)
|
||||
refnode.attributes.update(env.ref_context)
|
||||
return result
|
||||
|
||||
|
||||
def indexmarkup_role(typ, rawtext, text, lineno, inliner,
|
||||
options={}, content=[]):
|
||||
"""Role for PEP/RFC references that generate an index entry."""
|
||||
@ -319,7 +328,7 @@ specific_docroles = {
|
||||
# links to documents
|
||||
'doc': XRefRole(warn_dangling=True),
|
||||
# links to anything
|
||||
'any': XRefRole(warn_dangling=True),
|
||||
'any': AnyXRefRole(warn_dangling=True),
|
||||
|
||||
'pep': indexmarkup_role,
|
||||
'rfc': indexmarkup_role,
|
||||
|
Loading…
Reference in New Issue
Block a user