From 9a2ed057c448e3b6421c1040f1fbae8443d9a3e4 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Mon, 20 May 2024 12:56:47 -0400 Subject: [PATCH] Use an inner node class to override the text representation I'm probably butchering the Sphinx/docutils API here; apologies in advance --- Doc/tools/extensions/pyspecific.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py index 9c89e0b0d824cc..d5f240c20b64ef 100644 --- a/Doc/tools/extensions/pyspecific.py +++ b/Doc/tools/extensions/pyspecific.py @@ -692,9 +692,12 @@ def patch_pairindextypes(app, _env) -> None: class PyDecoratorRole(PyXRefRole): - def process_link(self, *args, **kwds): - title, target = super().process_link(*args, **kwds) - return f"@{title}", target + class inner(nodes.literal): + def __init__(self, raw, text, *args, **kwds): + super().__init__(raw, f"@{text}", *args, **kwds) + + def __init__(self, *args, **kwds): + super().__init__(*args, innernodeclass=PyDecoratorRole.inner, **kwds) def setup(app):