mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
make :any: role work with intersphinx!
This commit is contained in:
parent
e1169d0937
commit
a973daea41
@ -83,7 +83,7 @@ texinfo_documents = [
|
|||||||
|
|
||||||
# We're not using intersphinx right now, but if we did, this would be part of
|
# We're not using intersphinx right now, but if we did, this would be part of
|
||||||
# the mapping:
|
# the mapping:
|
||||||
intersphinx_mapping = {'python': ('http://docs.python.org/dev', None)}
|
intersphinx_mapping = {'python': ('http://docs.python.org/2/', None)}
|
||||||
|
|
||||||
# Sphinx document translation with sphinx gettext feature uses these settings:
|
# Sphinx document translation with sphinx gettext feature uses these settings:
|
||||||
locale_dirs = ['locale/']
|
locale_dirs = ['locale/']
|
||||||
|
@ -86,6 +86,10 @@ Cross-referencing anything
|
|||||||
Python module (usually ``:py:mod:`signal``` or ``:mod:`signal```) and a
|
Python module (usually ``:py:mod:`signal``` or ``:mod:`signal```) and a
|
||||||
section (usually ``:ref:`about-signals```).
|
section (usually ``:ref:`about-signals```).
|
||||||
|
|
||||||
|
The :rst:role:`any` role also works together with the
|
||||||
|
:mod:`~sphinx.ext.intersphinx` extension: when no local cross-reference is
|
||||||
|
found, all object types of intersphinx inventories are also searched.
|
||||||
|
|
||||||
|
|
||||||
Cross-referencing objects
|
Cross-referencing objects
|
||||||
-------------------------
|
-------------------------
|
||||||
|
@ -222,15 +222,21 @@ def load_mappings(app):
|
|||||||
|
|
||||||
def missing_reference(app, env, node, contnode):
|
def missing_reference(app, env, node, contnode):
|
||||||
"""Attempt to resolve a missing reference via intersphinx references."""
|
"""Attempt to resolve a missing reference via intersphinx references."""
|
||||||
domain = node.get('refdomain')
|
|
||||||
if not domain:
|
|
||||||
# only objects in domains are in the inventory
|
|
||||||
return
|
|
||||||
target = node['reftarget']
|
target = node['reftarget']
|
||||||
objtypes = env.domains[domain].objtypes_for_role(node['reftype'])
|
if node['reftype'] == 'any':
|
||||||
if not objtypes:
|
# we search anything!
|
||||||
return
|
objtypes = ['%s:%s' % (domain.name, objtype)
|
||||||
objtypes = ['%s:%s' % (domain, objtype) for objtype in objtypes]
|
for domain in env.domains.values()
|
||||||
|
for objtype in domain.object_types]
|
||||||
|
else:
|
||||||
|
domain = node.get('refdomain')
|
||||||
|
if not domain:
|
||||||
|
# only objects in domains are in the inventory
|
||||||
|
return
|
||||||
|
objtypes = env.domains[domain].objtypes_for_role(node['reftype'])
|
||||||
|
if not objtypes:
|
||||||
|
return
|
||||||
|
objtypes = ['%s:%s' % (domain, objtype) for objtype in objtypes]
|
||||||
to_try = [(env.intersphinx_inventory, target)]
|
to_try = [(env.intersphinx_inventory, target)]
|
||||||
in_set = None
|
in_set = None
|
||||||
if ':' in target:
|
if ':' in target:
|
||||||
@ -248,7 +254,7 @@ def missing_reference(app, env, node, contnode):
|
|||||||
# get correct path in case of subdirectories
|
# get correct path in case of subdirectories
|
||||||
uri = path.join(relative_path(node['refdoc'], env.srcdir), uri)
|
uri = path.join(relative_path(node['refdoc'], env.srcdir), uri)
|
||||||
newnode = nodes.reference('', '', internal=False, refuri=uri,
|
newnode = nodes.reference('', '', internal=False, refuri=uri,
|
||||||
reftitle=_('(in %s v%s)') % (proj, version))
|
reftitle=_('(in %s v%s)') % (proj, version))
|
||||||
if node.get('refexplicit'):
|
if node.get('refexplicit'):
|
||||||
# use whatever title was given
|
# use whatever title was given
|
||||||
newnode.append(contnode)
|
newnode.append(contnode)
|
||||||
|
Loading…
Reference in New Issue
Block a user