Skip to content

Commit

Permalink
Use an inner node class to override the text representation
Browse files Browse the repository at this point in the history
I'm probably butchering the Sphinx/docutils API here; apologies in advance
  • Loading branch information
erlend-aasland committed May 20, 2024
1 parent d6490bc commit 9a2ed05
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Doc/tools/extensions/pyspecific.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 9a2ed05

Please sign in to comment.