Skip to content

Commit 14524e0

Browse files
author
daniel.eades
committed
Merge branch 'master' into workflow-simplification
2 parents 31728e9 + ad360fd commit 14524e0

File tree

4 files changed

+29
-18
lines changed

4 files changed

+29
-18
lines changed

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Bugs fixed
3131

3232
* #13369: Correctly parse and cross-reference unpacked type annotations.
3333
Patch by Alicia Garcia-Raboso.
34+
* #13528: Add tilde ``~`` prefix support for :rst:role:`py:deco`.
35+
Patch by Shengyu Zhang and Adam Turner.
3436

3537
Testing
3638
-------

doc/extdev/event_callbacks.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ Below is an overview of the core event that happens during a build.
7070
14. apply post-transforms (by priority): docutils.document -> docutils.document
7171
15. event.doctree-resolved(app, doctree, docname)
7272
- In the event that any reference nodes fail to resolve, the following may emit:
73-
- event.missing-reference(env, node, contnode)
74-
- event.warn-missing-reference(domain, node)
73+
- event.missing-reference(app, env, node, contnode)
74+
- event.warn-missing-reference(app, domain, node)
7575
7676
16. Generate output files
7777
17. event.build-finished(app, exception)

sphinx/domains/python/__init__.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from collections.abc import Iterable, Iterator, Sequence, Set
3030
from typing import Any, ClassVar
3131

32-
from docutils.nodes import Element, Node, TextElement
32+
from docutils.nodes import Element, Node
3333

3434
from sphinx.addnodes import desc_signature, pending_xref
3535
from sphinx.application import Sphinx
@@ -594,23 +594,17 @@ def process_link(
594594

595595

596596
class _PyDecoXRefRole(PyXRefRole):
597-
def __init__(
597+
def process_link(
598598
self,
599-
fix_parens: bool = False,
600-
lowercase: bool = False,
601-
nodeclass: type[Element] | None = None,
602-
innernodeclass: type[TextElement] | None = None,
603-
warn_dangling: bool = False,
604-
) -> None:
605-
super().__init__(
606-
fix_parens=True,
607-
lowercase=lowercase,
608-
nodeclass=nodeclass,
609-
innernodeclass=innernodeclass,
610-
warn_dangling=warn_dangling,
599+
env: BuildEnvironment,
600+
refnode: Element,
601+
has_explicit_title: bool,
602+
title: str,
603+
target: str,
604+
) -> tuple[str, str]:
605+
title, target = super().process_link(
606+
env, refnode, has_explicit_title, title, target
611607
)
612-
613-
def update_title_and_target(self, title: str, target: str) -> tuple[str, str]:
614608
return f'@{title}', target
615609

616610

tests/test_domains/test_domain_py.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,3 +1791,18 @@ def test_pep_695_and_pep_696_whitespaces_in_default(app, tp_list, tptext):
17911791
text = f'.. py:function:: f{tp_list}() -> Annotated[T, Qux[int]()]'
17921792
doctree = restructuredtext.parse(app, text)
17931793
assert doctree.astext() == f'\n\nf{tptext}() -> Annotated[T, Qux[int]()]\n\n'
1794+
1795+
1796+
def test_deco_role(app):
1797+
text = """\
1798+
.. py:decorator:: foo.bar
1799+
:no-contents-entry:
1800+
:no-index-entry:
1801+
:no-typesetting:
1802+
"""
1803+
1804+
doctree = restructuredtext.parse(app, text + '\n:py:deco:`foo.bar`')
1805+
assert doctree.astext() == '\n\n\n\n@foo.bar'
1806+
1807+
doctree = restructuredtext.parse(app, text + '\n:py:deco:`~foo.bar`')
1808+
assert doctree.astext() == '\n\n\n\n@bar'

0 commit comments

Comments
 (0)