From e53838acfbcbd0556d6a6c545490e9f1ebeeca7f Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Sat, 4 Sep 2021 17:51:04 +0200 Subject: [PATCH] Use make_refnode for creating the references on the IP list --- jandd/sphinxext/ip.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/jandd/sphinxext/ip.py b/jandd/sphinxext/ip.py index 2352c92..0d3bfd9 100644 --- a/jandd/sphinxext/ip.py +++ b/jandd/sphinxext/ip.py @@ -346,30 +346,33 @@ def process_ip_nodes(app, doctree, fromdocname): tbody = nodes.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.literal("", ip_info[0][0].to_compressed()) ref_node = nodes.paragraph() - ref_uris = set() ref_nodes = [] + referenced_docs = set() for item in ip_info: 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] innernode = nodes.Text(title.astext()) - newnode.append(innernode) + newnode = make_refnode( + app.builder, + fromdocname, + todocname, + anchor, + innernode, + title.astext(), + ) + ref_nodes.append(newnode) for count in range(len(ref_nodes)): ref_node.append(ref_nodes[count])