Skip to content

Commit b58460a

Browse files
committed
correct backref (footnotes/citations) updates in singleconfluence
When the merging of documentation occurs for a `singleconfluence` run, identifiers are updated to ensure uniqueness. However, for citations and footnotes, the back references were not updated causing unexpected links on updated identifiers. To address this, when updating elements with new identifiers, check for back-references to be updated as well. Signed-off-by: James Knight <[email protected]>
1 parent 0e186e4 commit b58460a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

sphinxcontrib/confluencebuilder/singlebuilder.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,21 @@ def _inline_all_toctrees(self, docname, doctree, traversed, uids):
215215
target['ids'] = new_ids
216216

217217
for target in findall(tree, nodes.Element):
218+
# update any reference targets to their new identifier (if any)
218219
refid = target.get('refid')
219220
if refid:
220221
new_refid = updated_refids.get(refid)
221222
if new_refid:
222223
target['refid'] = new_refid
223224

225+
# update any back references to their new identifier (if any)
226+
backrefs = target.get('backrefs')
227+
if backrefs:
228+
for idx, backref in enumerate(backrefs):
229+
new_backref = updated_refids.get(backref)
230+
if new_backref:
231+
backrefs[idx] = new_backref
232+
224233
# in the cloned tree, look for other toctrees that we can include
225234
# into our new single tree
226235
toctreenodes = list(findall(tree, addnodes.toctree))

0 commit comments

Comments
 (0)