Skip to content

Fix clean_backref for extensions that have backrefs to inline elements. #499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 26, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion numpydoc/numpydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import hashlib
import itertools

from docutils.nodes import citation, Text, section, comment, reference
from docutils.nodes import citation, Text, section, comment, reference, inline
import sphinx
from sphinx.addnodes import pending_xref, desc_content
from sphinx.util import logging
Expand Down Expand Up @@ -149,6 +149,10 @@ def clean_backrefs(app, doc, docname):
for ref in _traverse_or_findall(doc, reference, descend=True):
for id_ in ref["ids"]:
known_ref_ids.add(id_)
# some extensions produce backrefs to inline elements
for ref in _traverse_or_findall(doc, inline, descend=True):
for id_ in ref["ids"]:
known_ref_ids.add(id_)
for citation_node in _traverse_or_findall(doc, citation, descend=True):
# remove backrefs to non-existent refs
citation_node["backrefs"] = [
Expand Down