Skip to content

Commit

Permalink
docs: Fix custom handler for missing references
Browse files Browse the repository at this point in the history
When resolving the xref we must resolve relative to the _current_
document, not the document of the target we are trying to link
to.
  • Loading branch information
wence- committed Jan 11, 2024
1 parent 6f9b0bd commit 4ae13fc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions python/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,22 +248,24 @@ def on_missing_reference(app, env, node, contnode):
if match := re.search("(.*)<.*>", reftarget):
reftarget = match.group(1)

# This is the document we're linking _from_, and hence where
# we should try and resolve the xref wrt.
refdoc = node.get("refdoc")
# Try to find the target prefixed with e.g. namespaces in case that's
# all that's missing. Include the empty prefix in case we're searching
# for a stripped template.
extra_prefixes = ["rmm::", "rmm::mr::", "mr::", ""]
for (name, dispname, type, docname, anchor, priority) in env.domains[
for (name, dispname, typ, docname, anchor, priority) in env.domains[
"cpp"
].get_objects():

for prefix in extra_prefixes:
if (
name == f"{prefix}{reftarget}"
or f"{prefix}{name}" == reftarget
):
return env.domains["cpp"].resolve_xref(
env,
docname,
refdoc,
app.builder,
node["reftype"],
name,
Expand Down

0 comments on commit 4ae13fc

Please sign in to comment.