Add handling for missing references

This commit is contained in:
Jan Dittberner 2016-04-24 15:04:07 +02:00
parent 0012b495b3
commit 334968385b

View file

@ -39,12 +39,15 @@ class IPXRefRole(XRefRole):
return title, target
def result_nodes(self, document, env, node, is_ref):
indexnode = addnodes.index()
targetid = 'index-%s' % env.new_serialno('index')
targetnode = nodes.target('', '', ids=[targetid])
idxtext = "%s; %s" % (node.astext(), env.docname)
indexnode['entries'] = [('single', idxtext, targetid, '', None)]
return [indexnode, targetnode, node], []
try:
indexnode = addnodes.index()
targetid = 'index-%s' % env.new_serialno('index')
targetnode = nodes.target('', '', ids=[targetid])
idxtext = "%s; %s" % (node.astext(), env.docname)
indexnode['entries'] = [('single', idxtext, targetid, '', None)]
return [indexnode, targetnode, node], []
except KeyError as e:
return [node], [e.args[0]]
class IPObject(ObjectDescription):
@ -166,7 +169,7 @@ class IPDomain(Domain):
if role is None:
return None
resnode = role.result_nodes(env.get_doctree(fromdocname),
env, node, None)[0][0]
env, node, True)[0][0]
if isinstance(resnode, addnodes.pending_xref):
text = node[0][0]
reporter = env.get_doctree(fromdocname).reporter