Use make_refnode for creating the references on the IP list

This commit is contained in:
Jan Dittberner 2021-09-04 17:51:04 +02:00
parent 49a3d89488
commit e53838acfb

View file

@ -346,30 +346,33 @@ def process_ip_nodes(app, doctree, fromdocname):
tbody = nodes.tbody() tbody = nodes.tbody()
tgroup += tbody tgroup += tbody
for ip_address_sig, ip_info in [(key, addresses[key]) for key in sorted(addresses, key=sort_by_ip)]: for ip_address_sig, ip_info in [
(key, addresses[key]) for key in sorted(addresses, key=sort_by_ip)
]:
para = nodes.paragraph() para = nodes.paragraph()
para += nodes.literal("", ip_info[0][0].to_compressed()) para += nodes.literal("", ip_info[0][0].to_compressed())
ref_node = nodes.paragraph() ref_node = nodes.paragraph()
ref_uris = set()
ref_nodes = [] ref_nodes = []
referenced_docs = set()
for item in ip_info: for item in ip_info:
ip_address, todocname, anchor = item ip_address, todocname, anchor = item
if todocname in referenced_docs:
continue
referenced_docs.add(todocname)
newnode = nodes.reference("", "", internal=True)
try:
newnode["refuri"] = app.builder.get_relative_uri(
fromdocname, todocname
)
if newnode["refuri"] in ref_uris:
continue
ref_uris.add(newnode["refuri"])
except NoUri:
pass
title = env.titles[todocname] title = env.titles[todocname]
innernode = nodes.Text(title.astext()) innernode = nodes.Text(title.astext())
newnode.append(innernode) newnode = make_refnode(
app.builder,
fromdocname,
todocname,
anchor,
innernode,
title.astext(),
)
ref_nodes.append(newnode) ref_nodes.append(newnode)
for count in range(len(ref_nodes)): for count in range(len(ref_nodes)):
ref_node.append(ref_nodes[count]) ref_node.append(ref_nodes[count])