Add handling for missing references
This commit is contained in:
parent
0012b495b3
commit
334968385b
1 changed files with 10 additions and 7 deletions
|
@ -39,12 +39,15 @@ class IPXRefRole(XRefRole):
|
||||||
return title, target
|
return title, target
|
||||||
|
|
||||||
def result_nodes(self, document, env, node, is_ref):
|
def result_nodes(self, document, env, node, is_ref):
|
||||||
|
try:
|
||||||
indexnode = addnodes.index()
|
indexnode = addnodes.index()
|
||||||
targetid = 'index-%s' % env.new_serialno('index')
|
targetid = 'index-%s' % env.new_serialno('index')
|
||||||
targetnode = nodes.target('', '', ids=[targetid])
|
targetnode = nodes.target('', '', ids=[targetid])
|
||||||
idxtext = "%s; %s" % (node.astext(), env.docname)
|
idxtext = "%s; %s" % (node.astext(), env.docname)
|
||||||
indexnode['entries'] = [('single', idxtext, targetid, '', None)]
|
indexnode['entries'] = [('single', idxtext, targetid, '', None)]
|
||||||
return [indexnode, targetnode, node], []
|
return [indexnode, targetnode, node], []
|
||||||
|
except KeyError as e:
|
||||||
|
return [node], [e.args[0]]
|
||||||
|
|
||||||
|
|
||||||
class IPObject(ObjectDescription):
|
class IPObject(ObjectDescription):
|
||||||
|
@ -166,7 +169,7 @@ class IPDomain(Domain):
|
||||||
if role is None:
|
if role is None:
|
||||||
return None
|
return None
|
||||||
resnode = role.result_nodes(env.get_doctree(fromdocname),
|
resnode = role.result_nodes(env.get_doctree(fromdocname),
|
||||||
env, node, None)[0][0]
|
env, node, True)[0][0]
|
||||||
if isinstance(resnode, addnodes.pending_xref):
|
if isinstance(resnode, addnodes.pending_xref):
|
||||||
text = node[0][0]
|
text = node[0][0]
|
||||||
reporter = env.get_doctree(fromdocname).reporter
|
reporter = env.get_doctree(fromdocname).reporter
|
||||||
|
|
Loading…
Reference in a new issue