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
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue