Add test suite

This commit adds a test suite and fixes replacement of ip address nodes
for IP addresses that are not part of a IP range directive.
This commit is contained in:
Jan Dittberner 2016-05-02 20:55:09 +02:00
parent a5c82a6985
commit 869039df5d
8 changed files with 113 additions and 15 deletions

View file

@ -189,18 +189,17 @@ class IPDomain(Domain):
if role is None:
return None
resnode = role.result_nodes(env.get_doctree(fromdocname),
env, node, True)[0][0]
env, node, True)[0][2]
if isinstance(resnode, addnodes.pending_xref):
text = node[0][0]
reporter = env.get_doctree(fromdocname).reporter
reporter.warning('Cannot resolve reference to %r' % text,
line=node.line)
return None
return node.children
return resnode
else:
title = typ.upper() + ' ' + target
anchor = ip_object_anchor(typ, target)
return make_refnode(builder, fromdocname, info[0], anchor,
return make_refnode(builder, fromdocname, info[0], key,
contnode, title)
@property
@ -227,7 +226,8 @@ def process_ips(app, doctree):
'ip': ip,
'typ': node.parent['typ'],
})
node.replace_self(nodes.literal('', ip))
replacement = nodes.literal(ip, ip)
node.replace_self(replacement)
def sort_ip_info(item):
@ -260,8 +260,6 @@ def process_ip_nodes(app, doctree, fromdocname):
para += nodes.Text(" in ")
para += newnode
content.append(para)
#print(ip_info, 'in', node['rangespec'])
node.replace_self(content)