mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
intersphinx: explicitly parse out inventory specification
This commit is contained in:
parent
454a1c599e
commit
36c6eafdf1
@ -495,10 +495,20 @@ class IntersphinxRole(SphinxRole):
|
|||||||
location=(self.env.docname, self.lineno))
|
location=(self.env.docname, self.lineno))
|
||||||
return [], []
|
return [], []
|
||||||
|
|
||||||
|
# extract inventory specification
|
||||||
|
inventory = None
|
||||||
|
if self.text.startswith('\\:'):
|
||||||
|
# escaped :, so not a real inventory specification
|
||||||
|
self.text = self.text[1:]
|
||||||
|
elif self.text[0] == ':': # format: :inv:normalRoleArg
|
||||||
|
inventory = self.text.split(':')[1]
|
||||||
|
self.text = self.text[(len(inventory) + 2):]
|
||||||
|
|
||||||
result, messages = self.invoke_role(role_name)
|
result, messages = self.invoke_role(role_name)
|
||||||
for node in result:
|
for node in result:
|
||||||
if isinstance(node, pending_xref):
|
if isinstance(node, pending_xref):
|
||||||
node['intersphinx'] = True
|
node['intersphinx'] = True
|
||||||
|
node['inventory'] = inventory
|
||||||
|
|
||||||
return result, messages
|
return result, messages
|
||||||
|
|
||||||
@ -555,6 +565,9 @@ class IntersphinxRoleResolver(ReferencesResolver):
|
|||||||
for node in self.document.traverse(pending_xref):
|
for node in self.document.traverse(pending_xref):
|
||||||
if 'intersphinx' in node:
|
if 'intersphinx' in node:
|
||||||
contnode = cast(nodes.TextElement, node[0].deepcopy())
|
contnode = cast(nodes.TextElement, node[0].deepcopy())
|
||||||
|
# temporary hax to glue on inventory info again
|
||||||
|
if node['inventory'] is not None:
|
||||||
|
node['reftarget'] = node['inventory'] + ":" + node['reftarget']
|
||||||
newnode = missing_reference(self.app, self.env, node, contnode)
|
newnode = missing_reference(self.app, self.env, node, contnode)
|
||||||
if newnode is None:
|
if newnode is None:
|
||||||
# no warning, the normal missing_reference handler will do that
|
# no warning, the normal missing_reference handler will do that
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
:external:cpp:type:`std::uint8_t`
|
:external:cpp:type:`std::uint8_t`
|
||||||
:external:cpp:class:`inv:foo::Bar`
|
:external:cpp:class:`inv:foo::Bar`
|
||||||
|
:external:cpp:func:`:inv2:foo::Bar::baz`
|
||||||
|
|
||||||
:external:cpp:type:`FoonsTitle <foons>`
|
:external:cpp:type:`FoonsTitle <foons>`
|
||||||
:external:cpp:type:`inv:BarType <foons::bartype>`
|
:external:cpp:type:`inv:BarType <foons::bartype>`
|
@ -558,3 +558,5 @@ def test_intersphinx_role(app):
|
|||||||
html = '<a class="reference external" href="http://example.org/{}" title="(in foo v2.0)">'
|
html = '<a class="reference external" href="http://example.org/{}" title="(in foo v2.0)">'
|
||||||
for t in targets:
|
for t in targets:
|
||||||
assert html.format(t) in content
|
assert html.format(t) in content
|
||||||
|
|
||||||
|
assert html.format('index.html#cpp_foo_bar_baz') not in content
|
||||||
|
Loading…
Reference in New Issue
Block a user