Skip to content

Commit c6c0189

Browse files
authored
Merge branch 'master' into latex_fontawesome6
2 parents 446dfe7 + 1a69059 commit c6c0189

File tree

145 files changed

+27883
-5563
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+27883
-5563
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,5 @@ tests/roots/test-pycode/cp_1251_coded.py working-tree-encoding=windows-1251
6262

6363
tests/js/fixtures/**/*.js generated
6464
sphinx/search/minified-js/*.js generated
65+
sphinx/search/_stopwords/ generated
6566
sphinx/themes/bizstyle/static/css3-mediaqueries.js generated

CHANGES.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,22 @@ Features added
1919
* #13439: linkcheck: Permit warning on every redirect with
2020
``linkcheck_allowed_redirects = {}``.
2121
Patch by Adam Turner.
22+
* #13497: Support C domain objects in the table of contents.
2223
* #13500: LaTeX: add support for ``fontawesome6`` package.
2324
Patch by Jean-François B.
25+
* #13535: html search: Update to the latest version of Snowball (v3.0.1).
26+
Patch by Adam Turner.
27+
* #13704: autodoc: Detect :py:func:`typing_extensions.overload <typing.overload>`
28+
and :py:func:`~typing.final` decorators.
29+
Patch by Spencer Brown.
2430

2531
Bugs fixed
2632
----------
2733

2834
* #13369: Correctly parse and cross-reference unpacked type annotations.
2935
Patch by Alicia Garcia-Raboso.
36+
* #13528: Add tilde ``~`` prefix support for :rst:role:`py:deco`.
37+
Patch by Shengyu Zhang and Adam Turner.
3038

3139
Testing
3240
-------

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)

doc/internals/contributing.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,13 +337,15 @@ Updating generated files
337337
------------------------
338338

339339
* JavaScript stemming algorithms in :file:`sphinx/search/non-minified-js/*.js`
340-
are generated using `snowball <https://github.com/snowballstem/snowball>`_
341-
by cloning the repository, executing ``make dist_libstemmer_js`` and then
342-
unpacking the tarball which is generated in :file:`dist` directory.
340+
and stopword files in :file:`sphinx/search/_stopwords/`
341+
are generated from the `Snowball project`_
342+
by running :file:`utils/generate_snowball.py`.
343343

344344
Minified files in :file:`sphinx/search/minified-js/*.js` are generated from
345-
non-minified ones using :program:`uglifyjs` (installed via npm), with ``-m``
346-
option to enable mangling.
345+
non-minified ones using :program:`uglifyjs` (installed via npm).
346+
See :file:`sphinx/search/minified-js/README.rst`.
347+
348+
.. _Snowball project: https://snowballstem.org/
347349

348350
* The :file:`searchindex.js` files found in
349351
the :file:`tests/js/fixtures/*` directories

doc/latex.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ Keys that don't need to be overridden unless in special cases are:
500500
.. hint::
501501

502502
If the key value is set to
503-
:code-tex:`'\\newcommand\\sphinxbackoftitlepage{<Extra
503+
:code-tex:`r'\\newcommand\\sphinxbackoftitlepage{<Extra
504504
material>}\\sphinxmaketitle'`, then ``<Extra material>`` will be
505505
typeset on back of title page (``'manual'`` docclass only).
506506

pyproject.toml

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,19 @@ docs = [
9292
"sphinxcontrib-websupport",
9393
]
9494
lint = [
95-
"ruff==0.11.9",
95+
"ruff==0.11.10",
9696
"mypy==1.15.0",
9797
"sphinx-lint>=0.9",
9898
"types-colorama==0.4.15.20240311",
99-
"types-defusedxml==0.7.0.20240218",
100-
"types-docutils==0.21.0.20241128",
99+
"types-defusedxml==0.7.0.20250516",
100+
"types-docutils==0.21.0.20250514",
101101
"types-Pillow==10.2.0.20240822",
102-
"types-Pygments==2.19.0.20250305",
103-
"types-requests==2.32.0.20250328", # align with requests
102+
"types-Pygments==2.19.0.20250516",
103+
"types-requests==2.32.0.20250515", # align with requests
104104
"types-urllib3==1.26.25.14",
105105
"pyright==1.1.400",
106106
"pytest>=8.0",
107-
"pypi-attestations==0.0.25",
107+
"pypi-attestations==0.0.26",
108108
"betterproto==2.0.0b6",
109109
]
110110
test = [
@@ -135,13 +135,13 @@ docs = [
135135
"sphinxcontrib-websupport",
136136
]
137137
lint = [
138-
"ruff==0.11.9",
138+
"ruff==0.11.10",
139139
"sphinx-lint>=0.9",
140140
]
141141
package = [
142142
"betterproto==2.0.0b6", # resolution fails without betterproto
143143
"build",
144-
"pypi-attestations==0.0.25",
144+
"pypi-attestations==0.0.26",
145145
"twine>=6.1",
146146
]
147147
test = [
@@ -164,11 +164,11 @@ types = [
164164
type-stubs = [
165165
# align with versions used elsewhere
166166
"types-colorama==0.4.15.20240311",
167-
"types-defusedxml==0.7.0.20240218",
168-
"types-docutils==0.21.0.20241128",
167+
"types-defusedxml==0.7.0.20250516",
168+
"types-docutils==0.21.0.20250514",
169169
"types-Pillow==10.2.0.20240822",
170-
"types-Pygments==2.19.0.20250305",
171-
"types-requests==2.32.0.20250328",
170+
"types-Pygments==2.19.0.20250516",
171+
"types-requests==2.32.0.20250515",
172172
"types-urllib3==1.26.25.14",
173173
]
174174

@@ -283,14 +283,10 @@ module = [
283283
"tests.test_theming.test_templating",
284284
"tests.test_theming.test_theming",
285285
# tests/test_transforms
286-
"tests.test_transforms.test_transforms_move_module_targets",
287286
"tests.test_transforms.test_transforms_post_transforms_images",
288287
"tests.test_transforms.test_transforms_reorder_nodes",
289288
# tests/test_util
290-
"tests.test_util.test_util",
291-
"tests.test_util.test_util_display",
292289
"tests.test_util.test_util_docutils",
293-
"tests.test_util.test_util_inventory",
294290
# tests/test_writers
295291
"tests.test_writers.test_docutilsconf",
296292
]
@@ -333,13 +329,9 @@ module = [
333329
"tests.test_extensions.test_ext_napoleon_docstring",
334330
# tests/test_intl
335331
"tests.test_intl.test_intl",
336-
# tests/test_pycode
337-
"tests.test_pycode.test_pycode",
338-
"tests.test_pycode.test_pycode_ast",
339332
# tests/test_transforms
340333
"tests.test_transforms.test_transforms_post_transforms",
341334
# tests/test_util
342-
"tests.test_util.test_util_fileutil",
343335
"tests.test_util.test_util_i18n",
344336
"tests.test_util.test_util_inspect",
345337
"tests.test_util.test_util_logging",

sphinx/directives/other.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from pathlib import Path
66
from typing import TYPE_CHECKING, cast
77

8-
import docutils
98
from docutils import nodes
109
from docutils.parsers.rst import directives
1110
from docutils.parsers.rst.directives.misc import Class
@@ -22,15 +21,14 @@
2221

2322
if TYPE_CHECKING:
2423
from collections.abc import Sequence
25-
from typing import Any, ClassVar, Final
24+
from typing import Any, ClassVar
2625

2726
from docutils.nodes import Element, Node
2827

2928
from sphinx.application import Sphinx
3029
from sphinx.util.typing import ExtensionMetadata, OptionSpec
3130

3231

33-
DU_22_PLUS: Final = docutils.__version_info__ >= (0, 22, 0, 'alpha', 0)
3432
glob_re = re.compile(r'.*[*?\[].*')
3533
logger = logging.getLogger(__name__)
3634

@@ -332,14 +330,6 @@ def run(self) -> list[Node]:
332330
surrounding_section_level = memo.section_level
333331
memo.title_styles = []
334332
memo.section_level = 0
335-
if DU_22_PLUS:
336-
# https://github.com/sphinx-doc/sphinx/issues/13539
337-
# https://sourceforge.net/p/docutils/code/10093/
338-
# https://sourceforge.net/p/docutils/patches/213/
339-
surrounding_section_parents = memo.section_parents
340-
memo.section_parents = []
341-
else:
342-
surrounding_section_parents = []
343333
try:
344334
self.state.nested_parse(
345335
self.content, self.content_offset, node, match_titles=True
@@ -375,8 +365,6 @@ def run(self) -> list[Node]:
375365
return []
376366
finally:
377367
memo.title_styles = surrounding_title_styles
378-
if DU_22_PLUS:
379-
memo.section_parents = surrounding_section_parents
380368
memo.section_level = surrounding_section_level
381369

382370

sphinx/domains/c/__init__.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
from docutils.nodes import Element, Node, TextElement, system_message
4141

42-
from sphinx.addnodes import pending_xref
42+
from sphinx.addnodes import desc_signature, pending_xref
4343
from sphinx.application import Sphinx
4444
from sphinx.builders import Builder
4545
from sphinx.domains.c._symbol import LookupKey
@@ -309,6 +309,32 @@ def after_content(self) -> None:
309309
self.env.current_document.c_parent_symbol = self.oldParentSymbol
310310
self.env.ref_context['c:parent_key'] = self.oldParentKey
311311

312+
def _object_hierarchy_parts(self, sig_node: desc_signature) -> tuple[str, ...]:
313+
last_symbol: Symbol = self.env.current_document.c_last_symbol
314+
return tuple(map(str, last_symbol.get_full_nested_name().names))
315+
316+
def _toc_entry_name(self, sig_node: desc_signature) -> str:
317+
if not sig_node.get('_toc_parts'):
318+
return ''
319+
320+
config = self.config
321+
objtype = sig_node.parent.get('objtype')
322+
if config.add_function_parentheses and (
323+
objtype in {'function', 'method'}
324+
or (objtype == 'macro' and '(' in sig_node.rawsource)
325+
):
326+
parens = '()'
327+
else:
328+
parens = ''
329+
*parents, name = sig_node['_toc_parts']
330+
if config.toc_object_entries_show_parents == 'domain':
331+
return '::'.join((name + parens,))
332+
if config.toc_object_entries_show_parents == 'hide':
333+
return name + parens
334+
if config.toc_object_entries_show_parents == 'all':
335+
return '::'.join([*parents, name + parens])
336+
return ''
337+
312338

313339
class CMemberObject(CObject):
314340
object_type = 'member'

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

sphinx/pycode/parser.py

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@ def __init__(self, buffers: list[str], encoding: str) -> None:
247247
self.deforders: dict[str, int] = {}
248248
self.finals: list[str] = []
249249
self.overloads: dict[str, list[Signature]] = {}
250-
self.typing: str | None = None
251-
self.typing_final: str | None = None
252-
self.typing_overload: str | None = None
250+
self.typing_mods: set[str] = set()
251+
self.typing_final_names: set[str] = set()
252+
self.typing_overload_names: set[str] = set()
253253
super().__init__()
254254

255255
def get_qualname_for(self, name: str) -> list[str] | None:
@@ -295,11 +295,8 @@ def add_variable_annotation(self, name: str, annotation: ast.AST) -> None:
295295
self.annotations[basename, name] = ast_unparse(annotation)
296296

297297
def is_final(self, decorators: list[ast.expr]) -> bool:
298-
final = []
299-
if self.typing:
300-
final.append('%s.final' % self.typing)
301-
if self.typing_final:
302-
final.append(self.typing_final)
298+
final = {f'{modname}.final' for modname in self.typing_mods}
299+
final |= self.typing_final_names
303300

304301
for decorator in decorators:
305302
try:
@@ -311,11 +308,8 @@ def is_final(self, decorators: list[ast.expr]) -> bool:
311308
return False
312309

313310
def is_overload(self, decorators: list[ast.expr]) -> bool:
314-
overload = []
315-
if self.typing:
316-
overload.append('%s.overload' % self.typing)
317-
if self.typing_overload:
318-
overload.append(self.typing_overload)
311+
overload = {f'{modname}.overload' for modname in self.typing_mods}
312+
overload |= self.typing_overload_names
319313

320314
for decorator in decorators:
321315
try:
@@ -348,22 +342,24 @@ def visit_Import(self, node: ast.Import) -> None:
348342
for name in node.names:
349343
self.add_entry(name.asname or name.name)
350344

351-
if name.name == 'typing':
352-
self.typing = name.asname or name.name
353-
elif name.name == 'typing.final':
354-
self.typing_final = name.asname or name.name
355-
elif name.name == 'typing.overload':
356-
self.typing_overload = name.asname or name.name
345+
if name.name in {'typing', 'typing_extensions'}:
346+
self.typing_mods.add(name.asname or name.name)
347+
elif name.name in {'typing.final', 'typing_extensions.final'}:
348+
self.typing_final_names.add(name.asname or name.name)
349+
elif name.name in {'typing.overload', 'typing_extensions.overload'}:
350+
self.typing_overload_names.add(name.asname or name.name)
357351

358352
def visit_ImportFrom(self, node: ast.ImportFrom) -> None:
359353
"""Handles Import node and record the order of definitions."""
360354
for name in node.names:
361355
self.add_entry(name.asname or name.name)
362356

363-
if node.module == 'typing' and name.name == 'final':
364-
self.typing_final = name.asname or name.name
365-
elif node.module == 'typing' and name.name == 'overload':
366-
self.typing_overload = name.asname or name.name
357+
if node.module not in {'typing', 'typing_extensions'}:
358+
continue
359+
if name.name == 'final':
360+
self.typing_final_names.add(name.asname or name.name)
361+
elif name.name == 'overload':
362+
self.typing_overload_names.add(name.asname or name.name)
367363

368364
def visit_Assign(self, node: ast.Assign) -> None:
369365
"""Handles Assign node and pick up a variable comment."""

0 commit comments

Comments
 (0)