Skip to content

Commit a7efc87

Browse files
authored
Merge branch 'master' into core/deprecate-intersphinx-1-0
2 parents 52222af + 5562e2b commit a7efc87

Some content is hidden

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

65 files changed

+1037
-570
lines changed

.github/workflows/main.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ jobs:
3939
- "3.13-dev"
4040
docutils:
4141
- "0.18"
42-
- "0.20"
42+
- "0.21"
4343
include:
4444
# test every supported Docutils version for the latest supported Python
4545
- python: "3.12"
4646
docutils: "0.19"
47+
- python: "3.12"
48+
docutils: "0.20"
4749

4850
steps:
4951
- uses: actions/checkout@v4
@@ -98,6 +100,11 @@ jobs:
98100
name: Docutils HEAD
99101

100102
steps:
103+
- name: Install epubcheck
104+
run: |
105+
mkdir /tmp/epubcheck && cd /tmp/epubcheck
106+
wget https://github.com/w3c/epubcheck/releases/download/v5.1.0/epubcheck-5.1.0.zip
107+
unzip epubcheck-5.1.0.zip
101108
- uses: actions/checkout@v4
102109
- name: Set up Python
103110
uses: actions/setup-python@v5
@@ -117,6 +124,8 @@ jobs:
117124
run: python -m pytest -vv
118125
env:
119126
PYTHONWARNINGS: "error" # treat all warnings as errors
127+
DO_EPUBCHECK: "1"
128+
EPUBCHECK_PATH: "/tmp/epubcheck/epubcheck-5.1.0/epubcheck.jar"
120129

121130
latex:
122131
runs-on: ubuntu-latest

.ruff.toml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,23 @@ exclude = [
1515
"doc/usage/extensions/example*.py",
1616
]
1717
ignore = [
18+
# flake8-annotations
1819
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed in `{name}`
20+
# pycodestyle
1921
"E741", # Ambiguous variable name: `{name}`
22+
# pyflakes
2023
"F841", # Local variable `{name}` is assigned to but never used
24+
# refurb
2125
"FURB101", # `open` and `read` should be replaced by `Path(...).read_text(...)`
26+
"FURB103", # `open` and `write` should be replaced by `Path(...).write_text(...)`
27+
# pylint
2228
"PLC1901", # simplify truthy/falsey string comparisons
29+
# flake8-simplify
2330
"SIM102", # Use a single `if` statement instead of nested `if` statements
2431
"SIM108", # Use ternary operator `{contents}` instead of `if`-`else`-block
32+
# pyupgrade
2533
"UP031", # Use format specifiers instead of percent format
2634
"UP032", # Use f-string instead of `format` call
27-
2835
]
2936
external = [ # Whitelist for RUF100 unknown code warnings
3037
"E704",
@@ -35,7 +42,8 @@ select = [
3542
# NOT YET USED
3643
# airflow ('AIR')
3744
# Airflow is not used in Sphinx
38-
"ANN", # flake8-annotations ('ANN')
45+
# flake8-annotations ('ANN')
46+
"ANN",
3947
# flake8-unused-arguments ('ARG')
4048
"ARG004", # Unused static method argument: `{name}`
4149
# flake8-async ('ASYNC')
@@ -123,7 +131,8 @@ select = [
123131
# NOT YET USED
124132
# flynt ('FLY')
125133
# NOT YET USED
126-
"FURB", # refurb
134+
# refurb ('FURB')
135+
"FURB",
127136
# flake8-logging-format ('G')
128137
"G001", # Logging statement uses `str.format`
129138
# "G002", # Logging statement uses `%`
@@ -135,6 +144,7 @@ select = [
135144
"G202", # Logging statement has redundant `exc_info`
136145
# isort ('I')
137146
"I",
147+
# flake8-import-conventions ('ICN')
138148
"ICN", # flake8-import-conventions
139149
# flake8-no-pep420 ('INP')
140150
"INP",
@@ -326,16 +336,19 @@ select = [
326336
"S612", # Use of insecure `logging.config.listen` detected
327337
# "S701", # Using jinja2 templates with `autoescape=False` is dangerous and can lead to XSS. Ensure `autoescape=True` or use the `select_autoescape` function.
328338
# "S702", # Mako templates allow HTML and JavaScript rendering by default and are inherently open to XSS attacks
339+
# flake8-simplify ('SIM')
329340
"SIM", # flake8-simplify
330341
# flake8-self ('SLF')
331342
# NOT YET USED
332-
"SLOT", # flake8-slots
343+
# flake8-slots ('SLOT')
344+
"SLOT",
333345
# flake8-debugger ('T10')
334346
"T100", # Trace found: `{name}` used
335347
# flake8-print ('T20')
336348
"T201", # `print` found
337349
"T203", # `pprint` found
338-
"TCH", # flake8-type-checking
350+
# flake8-type-checking ('TCH')
351+
"TCH",
339352
# flake8-todos ('TD')
340353
# "TD001", # Invalid TODO tag: `{tag}`
341354
# "TD003", # Missing issue link on the line following this TODO
@@ -351,7 +364,8 @@ select = [
351364
# Trio is not used in Sphinx
352365
# tryceratops ('TRY')
353366
# NOT YET USED
354-
"UP001", # pyupgrade
367+
# pyupgrade ('UP')
368+
"UP",
355369
# pycodestyle ('W')
356370
"W191", # Indentation contains tabs
357371
# "W291", # Trailing whitespace
@@ -370,7 +384,10 @@ select = [
370384
"doc/conf.py" = ["INP001", "W605"]
371385
"doc/development/tutorials/examples/*" = ["INP001"]
372386
# allow print() in the tutorial
373-
"doc/development/tutorials/examples/recipe.py" = ["T201"]
387+
"doc/development/tutorials/examples/recipe.py" = [
388+
"FURB118",
389+
"T201"
390+
]
374391
"sphinx/domains/**" = ["FURB113"]
375392
"tests/test_domains/test_domain_cpp.py" = ["FURB113"]
376393

CHANGES.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Release 7.3.0 (in development)
44
Dependencies
55
------------
66

7+
* #11411: Support `Docutils 0.21`_. Patch by Adam Turner.
8+
9+
.. _Docutils 0.21: https://docutils.sourceforge.io/RELEASE-NOTES.html#release-0-21-2024-04-09
10+
711
Incompatible changes
812
--------------------
913

@@ -104,6 +108,8 @@ Bugs fixed
104108
responses as broken.
105109
Patch by James Addison.
106110
* #11868: linkcheck: added a distinct ``timeout`` reporting status code.
111+
This can be enabled by setting :confval:`linkcheck_report_timeouts_as_broken`
112+
to ``False``.
107113
Patch by James Addison.
108114
* #11869: Refresh the documentation for the ``linkcheck_timeout`` setting.
109115
Patch by James Addison.
@@ -150,6 +156,10 @@ Bugs fixed
150156
* #11970: singlehtml builder: make target URIs to be same-document references in
151157
the sense of :rfc:`RFC 3986, §4.4 <3986#section-4.4>`, e.g., ``index.html#foo``
152158
becomes ``#foo``. Patch by eanorige.
159+
* #12271: Partially revert Docutils' r9562__ to fix EPUB files.
160+
Patch by Adam Turner.
161+
162+
__ https://sourceforge.net/p/docutils/code/9562/
153163

154164
Testing
155165
-------
-5.64 KB
Loading
-15.9 KB
Loading

doc/_static/tutorial/lumache-furo.png

-10.7 KB
Loading
-14.4 KB
Loading
-8.49 KB
Loading

doc/_themes/sphinx13/theme.conf

Lines changed: 0 additions & 4 deletions
This file was deleted.

doc/_themes/sphinx13/theme.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[theme]
2+
inherit = "basic"
3+
pygments_style = { default = "default" }
4+
sidebars = []

doc/development/theming.rst

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,82 @@ Creating themes
3030
Themes take the form of either a directory or a zipfile (whose name is the
3131
theme name), containing the following:
3232

33-
* A :file:`theme.conf` file.
33+
* Either a :file:`theme.toml` file (preferred) or a :file:`theme.conf` file.
3434
* HTML templates, if needed.
3535
* A ``static/`` directory containing any static files that will be copied to the
3636
output static directory on build. These can be images, styles, script files.
3737

38+
Theme configuration (``theme.toml``)
39+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
40+
41+
The :file:`theme.toml` file is a TOML_ document,
42+
containing two tables: ``[theme]`` and ``[options]``.
43+
44+
The ``[theme]`` table defines the theme's settings:
45+
46+
* **inherit** (string): The name of the base theme from which to inherit
47+
settings, options, templates, and static files.
48+
All static files from theme 'ancestors' will be used.
49+
The theme will use all options defined in inherited themes.
50+
Finally, inherited themes will be used to locate missing templates
51+
(for example, if ``"basic"`` is used as the base theme, most templates will
52+
already be defined).
53+
54+
If set to ``"none"``, the theme will not inherit from any other theme.
55+
Inheritance is recursive, forming a chain of inherited themes
56+
(e.g. ``default`` -> ``classic`` -> ``basic`` -> ``none``).
57+
58+
* **stylesheets** (list of strings): A list of CSS filenames which will be
59+
included in generated HTML header.
60+
Setting the :confval:`html_style` config value will override this setting.
61+
62+
Other mechanisms for including multiple stylesheets include ``@import`` in CSS
63+
or using a custom HTML template with appropriate ``<link rel="stylesheet">`` tags.
64+
65+
* **sidebars** (list of strings): A list of sidebar templates.
66+
This can be overridden by the user via the :confval:`html_sidebars` config value.
67+
68+
* **pygments_style** (table): A TOML table defining the names of Pygments styles
69+
to use for highlighting syntax.
70+
The table has two recognised keys: ``default`` and ``dark``.
71+
The style defined in the ``dark`` key will be used when
72+
the CSS media query ``(prefers-color-scheme: dark)`` evaluates to true.
73+
74+
``[theme.pygments_style.default]`` can be overridden by the user via the
75+
:confval:`pygments_style` config value.
76+
77+
The ``[options]`` table defines the options for the theme.
78+
It is structured such that each key-value pair corresponds to a variable name
79+
and the corresponding default value.
80+
These options can be overridden by the user in :confval:`html_theme_options`
81+
and are accessible from all templates as ``theme_<name>``.
82+
83+
.. versionadded:: 7.3
84+
``theme.toml`` support.
85+
86+
.. _TOML: https://toml.io/en/
87+
88+
Exemplar :file:`theme.toml` file:
89+
90+
.. code-block:: toml
91+
92+
[theme]
93+
inherit = "basic"
94+
stylesheets = [
95+
"main-CSS-stylesheet.css",
96+
]
97+
sidebars = [
98+
"localtoc.html",
99+
"relations.html",
100+
"sourcelink.html",
101+
"searchbox.html",
102+
]
103+
# Style names from https://pygments.org/styles/
104+
pygments_style = { default = "style_name", dark = "dark_style" }
105+
106+
[options]
107+
variable = "default value"
108+
38109
Theme configuration (``theme.conf``)
39110
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
40111

@@ -89,6 +160,24 @@ Python :mod:`configparser` module) and has the following structure:
89160

90161
The stylesheet setting accepts multiple CSS filenames
91162

163+
Convert ``theme.conf`` to ``theme.toml``
164+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
165+
166+
INI-style theme configuration files (``theme.conf``) can be converted to TOML
167+
via a helper programme distributed with Sphinx.
168+
This is intended for one-time use, and may be removed without notice in a future
169+
version of Sphinx.
170+
171+
.. code-block:: console
172+
173+
$ python -m sphinx.theming conf_to_toml [THEME DIRECTORY PATH]
174+
175+
The required argument is a path to a directory containing a ``theme.conf`` file.
176+
The programme will write a ``theme.toml`` file in the same directory,
177+
and will not modify the original ``theme.conf`` file.
178+
179+
.. versionadded:: 7.3
180+
92181
.. _distribute-your-theme:
93182

94183
Distribute your theme as a Python package

doc/internals/release-process.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ Date Python
117117
05 Apr 2024 3.10+
118118
----------- ------
119119
04 Apr 2025 3.11+
120+
----------- ------
121+
24 Apr 2026 3.12+
120122
=========== ======
121123

122124
Release procedures

doc/usage/configuration.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2971,6 +2971,21 @@ Options for the linkcheck builder
29712971

29722972
.. versionadded:: 7.3
29732973

2974+
.. confval:: linkcheck_report_timeouts_as_broken
2975+
2976+
When an HTTP response is not received from a webserver before the configured
2977+
:confval:`linkcheck_timeout` expires,
2978+
the current default behaviour of Sphinx is to treat the link as 'broken'.
2979+
To report timeouts using a distinct report code of ``timeout``,
2980+
set :confval:`linkcheck_report_timeouts_as_broken` to ``False``.
2981+
2982+
From Sphinx 8.0 onwards, timeouts that occur while checking hyperlinks
2983+
will be reported using the new 'timeout' status code.
2984+
2985+
.. xref RemovedInSphinx80Warning
2986+
2987+
.. versionadded:: 7.3
2988+
29742989

29752990
Options for the XML builder
29762991
---------------------------

doc/usage/theming.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ page's top and bottom), add the following :file:`conf.py`::
5656

5757
If the theme does not come with Sphinx, it can be in two static forms or as a
5858
Python package. For the static forms, either a directory (containing
59-
:file:`theme.conf` and other needed files), or a zip file with the same
59+
:file:`theme.toml` and other needed files), or a zip file with the same
6060
contents is supported. The directory or zipfile must be put where Sphinx can
6161
find it; for this there is the config value :confval:`html_theme_path`. This
6262
can be a list of directories, relative to the directory containing

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ dependencies = [
6464
"sphinxcontrib-qthelp",
6565
"Jinja2>=3.0",
6666
"Pygments>=2.14",
67-
"docutils>=0.18.1,<0.21",
67+
"docutils>=0.18.1,<0.22",
6868
"snowballstemmer>=2.0",
6969
"babel>=2.9",
7070
"alabaster~=0.7.14",
@@ -82,11 +82,13 @@ docs = [
8282
]
8383
lint = [
8484
"flake8>=3.5.0",
85-
"ruff==0.3.4",
85+
"ruff==0.3.7",
8686
"mypy==1.9.0",
8787
"sphinx-lint",
8888
"types-docutils",
8989
"types-requests",
90+
"importlib_metadata", # for mypy (Python<=3.9)
91+
"tomli", # for mypy (Python<=3.10)
9092
"pytest>=6.0",
9193
]
9294
test = [

sphinx/builders/gettext.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
import operator
56
import time
67
from codecs import open
78
from collections import defaultdict
@@ -281,7 +282,7 @@ def finish(self) -> None:
281282
__("writing message catalogs... "),
282283
"darkgreen", len(self.catalogs),
283284
self.app.verbosity,
284-
lambda textdomain__: textdomain__[0]):
285+
operator.itemgetter(0)):
285286
# noop if config.gettext_compact is set
286287
ensuredir(path.join(self.outdir, path.dirname(textdomain)))
287288

0 commit comments

Comments
 (0)