Skip to content

Commit 3d9813d

Browse files
committed
Merge remote-tracking branch 'upstream/master' into untyped-call
2 parents 7901b72 + 85a0870 commit 3d9813d

File tree

66 files changed

+4696
-4222
lines changed

Some content is hidden

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

66 files changed

+4696
-4222
lines changed

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ Contributors
103103
* Stefan Seefeld -- toctree improvements
104104
* Stefan van der Walt -- autosummary extension
105105
* Steve Piercy -- documentation improvements
106+
* Szymon Karpinski -- intersphinx improvements
106107
* \T. Powers -- HTML output improvements
107108
* Taku Shimizu -- epub3 builder
108109
* Thomas Lamb -- linkcheck builder

CHANGES.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,22 @@ Features added
6262
Bugs fixed
6363
----------
6464

65+
* #1327: LaTeX: tables using longtable raise error if
66+
:rst:dir:`tabularcolumns` specifies automatic widths
67+
(``L``, ``R``, ``C``, or ``J``).
68+
Patch by Jean-François B.
69+
* #3447: LaTeX: when assigning longtable class to table for PDF, it may render
70+
"horizontally" and overflow in right margin.
71+
Patch by Jean-François B.
72+
* #8828: LaTeX: adding a footnote to a longtable cell causes table to occupy
73+
full width.
74+
Patch by Jean-François B.
6575
* #11498: LaTeX: Table in cell fails to build if it has many rows.
6676
Patch by Jean-François B.
6777
* #11515: LaTeX: longtable does not allow nested table.
6878
Patch by Jean-François B.
79+
* #11973: LaTeX: links in table captions do not work in PDF.
80+
Patch by Jean-François B.
6981
* #12821: LaTeX: URLs/links in section titles should render in PDF.
7082
Patch by Jean-François B.
7183
* #13369: Correctly parse and cross-reference unpacked type annotations.
@@ -83,6 +95,8 @@ Bugs fixed
8395
Patch by Jean-François B.
8496
* #13685: gettext: Correctly ignore trailing backslashes.
8597
Patch by Bénédikt Tran.
98+
* #13712: intersphinx: Don't add "v" prefix to non-numeric versions.
99+
Patch by Szymon Karpinski.
86100

87101
Testing
88102
-------

doc/changes/5.3.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ Release 5.3.0 (released Oct 16, 2022)
88

99
* #10759: LaTeX: add :confval:`latex_table_style` and support the
1010
``'booktabs'``, ``'borderless'``, and ``'colorrows'`` styles.
11-
(thanks to Stefan Wiehler for initial pull requests #6666, #6671)
11+
(thanks to Stefan Wiehler for initial pull requests #6666, #6671).
12+
Using the ``'booktabs'`` style solves #6740 (Removing LaTeX
13+
column borders for automatic colspec).
14+
Patch by Jean-François B.
1215
* #10840: One can cross-reference including an option value like
1316
``:option:`--module=foobar```, ``:option:`--module[=foobar]```,
1417
or ``:option:`--module foobar```.

doc/internals/contributing.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ These are the basic steps needed to start developing on Sphinx.
138138

139139
#. Wait for a core developer or contributor to review your changes.
140140

141+
You may be asked to address comments on the review. If so, please avoid
142+
force pushing to the branch. Sphinx uses the *squash merge* strategy when
143+
merging PRs, so follow-up commits will all be combined.
144+
141145

142146
Coding style
143147
~~~~~~~~~~~~

doc/usage/restructuredtext/directives.rst

Lines changed: 66 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,60 +1483,95 @@ Check the :confval:`latex_table_style`.
14831483

14841484
.. rst:directive:: .. tabularcolumns:: column spec
14851485
1486-
This directive influences only the LaTeX output for the next table in
1487-
source. The mandatory argument is a column specification (known as an
1488-
"alignment preamble" in LaTeX idiom). Please refer to a LaTeX
1486+
This directive influences only the LaTeX output, and only for the next
1487+
table in source. The mandatory argument is a column specification (known
1488+
as an "alignment preamble" in LaTeX idiom). Please refer to a LaTeX
14891489
documentation, such as the `wiki page`_, for basics of such a column
14901490
specification.
14911491

14921492
.. _wiki page: https://en.wikibooks.org/wiki/LaTeX/Tables
14931493

14941494
.. versionadded:: 0.3
14951495

1496+
Sphinx renders tables with at most 30 rows using ``tabulary`` (or
1497+
``tabular`` if at least one cell contains either a code-block or a nested
1498+
table), and those with more rows with ``longtable``. The advantage of
1499+
using ``tabulary`` is that it tries to compute automatically (internally to
1500+
LaTeX) suitable column widths.
1501+
1502+
The ``tabulary`` algorithm often works well, but in some cases when a cell
1503+
contains long paragraphs, the column will be given a large width and other
1504+
columns whose cells contain only single words may end up too narrow. The
1505+
:rst:dir:`tabularcolumns` can help solve this via providing to LaTeX a
1506+
custom "alignment preamble" (aka "colspec"). For example ``lJJ`` will be
1507+
suitable for a three-columns table whose first column contains only single
1508+
words and the other two have cells with long paragraphs.
1509+
14961510
.. note::
14971511

1498-
:rst:dir:`tabularcolumns` conflicts with ``:widths:`` option of table
1499-
directives. If both are specified, ``:widths:`` option will be ignored.
1512+
Of course, a fully automated solution would be better, and it is still
1513+
hoped for, but it is an intrinsic aspect of ``tabulary``, and the latter
1514+
is in use by Sphinx ever since ``0.3``... It looks as if solving the
1515+
problem of squeezed columns could require substantial changes to that
1516+
LaTeX package. And no good alternative appears to exist, as of 2025.
1517+
1518+
.. hint::
1519+
1520+
A way to solve the issue for all tables at once, is to inject in the
1521+
LaTeX preamble (see :confval:`latex_elements`) a command such as
1522+
``\setlength{\tymin}{1cm}`` which causes all columns to be at least
1523+
``1cm`` wide (not counting inter-column whitespace). Currently, Sphinx
1524+
configures ``\tymin`` to allow room for three characters at least.
15001525

1501-
Sphinx renders tables with at most 30 rows using ``tabulary``, and those
1502-
with more rows with ``longtable``.
1526+
Here is a more sophisticated "colspec", for a 4-columns table:
15031527

1504-
``tabulary`` tries to compute automatically (internally to LaTeX) suitable
1505-
column widths. However, cells are then not allowed to contain
1506-
"problematic" elements such as lists, object descriptions,
1507-
blockquotes... Sphinx will fall back to using ``tabular`` if such a cell is
1508-
encountered (or a nested ``tabulary``). In such a case the table will have
1509-
a tendency to try to fill the whole available line width.
1528+
.. code-block:: latex
15101529

1511-
:rst:dir:`tabularcolumns` can help in coercing the usage of ``tabulary`` if
1512-
one is careful to not employ the ``tabulary`` column types (``L``, ``R``,
1513-
``C`` or ``J``) for those columns with at least one "problematic" cell, but
1514-
only LaTeX's ``p{<width>}`` or Sphinx ``\X`` and ``\Y`` (described next).
1530+
.. tabularcolumns:: >{\raggedright}\Y{.4}>{\centering}\Y{.1}>{\sphinxcolorblend{!95!red}\centering\noindent\bfseries\color{red}}\Y{.12}>{\raggedright\arraybackslash}\Y{.38}
15151531

1516-
Literal blocks do not work at all with ``tabulary``. Sphinx will fall back
1517-
to ``tabular`` or ``longtable`` environments depending on the number of
1518-
rows. It will employ the :rst:dir:`tabularcolumns` specification only if it
1519-
contains no usage of the ``tabulary`` specific types.
1532+
This is used in Sphinx own PDF docs at :ref:`dev-deprecated-apis`.
1533+
Regarding column widths, this "colspec" achieves the same as would
1534+
``:widths:`` option set to ``40 10 12 38`` but it injects extra effects.
1535+
1536+
.. note::
1537+
1538+
In case both :rst:dir:`tabularcolumns` and ``:widths:`` option of table
1539+
directives are used, ``:widths:`` option will be ignored by the LaTeX
1540+
builder. Of course it is obeyed by other builders.
1541+
1542+
Literal blocks do not work at all with ``tabulary`` and Sphinx will then
1543+
fall back to ``tabular`` LaTeX environment. It will employ the
1544+
:rst:dir:`tabularcolumns` specification in that case only if it contains no
1545+
usage of the ``tabulary`` specific column types (which are ``L``, ``R``,
1546+
``C`` and ``J``).
15201547

15211548
Besides the LaTeX ``l``, ``r``, ``c`` and ``p{width}`` column specifiers,
1522-
one can also use ``\X{a}{b}`` which configures the column width to be a
1523-
fraction ``a/b`` of the total line width and ``\Y{f}`` where ``f`` is a
1524-
decimal: for example ``\Y{0.2}`` means that the column will occupy ``0.2``
1525-
times the line width.
1549+
and the ``tabulary`` specific ``L``, ``R``, ``C`` and ``J``, one can also
1550+
use (with all table types) ``\X{a}{b}`` which configures the column width
1551+
to be a fraction ``a/b`` of the total line width and ``\Y{f}`` where ``f``
1552+
is a decimal: for example ``\Y{0.2}`` means that the column will occupy
1553+
``0.2`` times the line width.
15261554

15271555
.. versionchanged:: 1.6
15281556

1529-
Use ``J`` (justified) by default with ``tabulary``, not ``L``
1557+
Sphinx uses ``J`` (justified) by default with ``tabulary``, not ``L``
15301558
(flushed-left). To revert, include ``\newcolumntype{T}{L}`` in the LaTeX
15311559
preamble, as in fact Sphinx uses ``T`` and sets it by default to be an
15321560
alias of ``J``.
15331561

1534-
.. hint::
1562+
.. versionchanged:: 8.3.0
15351563

1536-
A frequent issue with ``tabulary`` is that columns with little contents
1537-
appear to be "squeezed". One can add to the LaTeX preamble for example
1538-
``\setlength{\tymin}{40pt}`` to ensure a minimal column width of ``40pt``,
1539-
the ``tabulary`` default of ``10pt`` being too small.
1564+
Formerly, Sphinx did not use ``tabulary`` if the table had at least one
1565+
cell containing "problematic" elements such as lists, object descriptions,
1566+
blockquotes (etc...) because such contents are not out-of-the-box
1567+
compatible with ``tabulary``. At ``8.3.0`` a technique, which was already
1568+
in use for merged cells, was extended to such cases, and the sole
1569+
"problematic" contents are code-blocks and nested tables. So tables
1570+
containing (only) cells with mutliple paragraphs, bullet or enumerated
1571+
lists, or line blocks, will now better fit to their contents (if not
1572+
rendered by ``longtable``). Cells with object descriptions or admonitions
1573+
will still have a tendency to induce the table to fill the full text area
1574+
width, but columns in that table with no such contents will be tighter.
15401575

15411576
.. hint::
15421577

pyproject.toml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,19 @@ docs = [
9393
"sphinxcontrib-websupport",
9494
]
9595
lint = [
96-
"ruff==0.12.0",
97-
"mypy==1.16.1",
96+
"ruff==0.12.5",
97+
"mypy==1.17.0",
9898
"sphinx-lint>=0.9",
9999
"types-colorama==0.4.15.20240311",
100-
"types-defusedxml==0.7.0.20250516",
100+
"types-defusedxml==0.7.0.20250708",
101101
"types-docutils==0.21.0.20250525",
102102
"types-Pillow==10.2.0.20240822",
103-
"types-Pygments==2.19.0.20250516",
103+
"types-Pygments==2.19.0.20250715",
104104
"types-requests==2.32.4.20250611", # align with requests
105105
"types-urllib3==1.26.25.14",
106106
"pyright==1.1.400",
107107
"pytest>=8.0",
108-
"pypi-attestations==0.0.26",
108+
"pypi-attestations==0.0.27",
109109
"betterproto==2.0.0b6",
110110
]
111111
test = [
@@ -136,13 +136,13 @@ docs = [
136136
"sphinxcontrib-websupport",
137137
]
138138
lint = [
139-
"ruff==0.12.0",
139+
"ruff==0.12.5",
140140
"sphinx-lint>=0.9",
141141
]
142142
package = [
143143
"betterproto==2.0.0b6", # resolution fails without betterproto
144144
"build",
145-
"pypi-attestations==0.0.26",
145+
"pypi-attestations==0.0.27",
146146
"twine>=6.1",
147147
]
148148
test = [
@@ -158,18 +158,18 @@ translations = [
158158
"Jinja2>=3.1",
159159
]
160160
types = [
161-
"mypy==1.16.1",
161+
"mypy==1.17.0",
162162
"pyrefly",
163163
"pyright==1.1.400",
164164
{ include-group = "type-stubs" },
165165
]
166166
type-stubs = [
167167
# align with versions used elsewhere
168168
"types-colorama==0.4.15.20240311",
169-
"types-defusedxml==0.7.0.20250516",
169+
"types-defusedxml==0.7.0.20250708",
170170
"types-docutils==0.21.0.20250525",
171171
"types-Pillow==10.2.0.20240822",
172-
"types-Pygments==2.19.0.20250516",
172+
"types-Pygments==2.19.0.20250715",
173173
"types-requests==2.32.4.20250611",
174174
"types-urllib3==1.26.25.14",
175175
]
@@ -257,7 +257,6 @@ module = [
257257
"tests.test_builders.test_build_html_assets",
258258
"tests.test_builders.test_build_html_maths",
259259
"tests.test_builders.test_build_html_numfig",
260-
"tests.test_builders.test_build_html_tocdepth",
261260
"tests.test_builders.test_build_html_toctree",
262261
"tests.test_builders.test_build_linkcheck",
263262
"tests.test_builders.test_build_warnings",
@@ -295,7 +294,6 @@ disallow_untyped_defs = false
295294
[[tool.mypy.overrides]]
296295
module = [
297296
# tests/
298-
"tests.test_quickstart",
299297
"tests.test_search",
300298
# tests/test_builders
301299
"tests.test_builders.test_build_latex",

sphinx/application.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252
from sphinx.config import ENUM, _ConfigRebuild
5353
from sphinx.domains import Domain, Index
5454
from sphinx.environment.collectors import EnvironmentCollector
55-
from sphinx.ext.autodoc import Documenter, _AutodocProcessDocstringListener
55+
from sphinx.ext.autodoc._documenters import Documenter
56+
from sphinx.ext.autodoc._event_listeners import _AutodocProcessDocstringListener
5657
from sphinx.ext.todo import todo_node
5758
from sphinx.extension import Extension
5859
from sphinx.registry import (

sphinx/cmd/quickstart.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@
8989

9090

9191
# function to get input from terminal -- overridden by the test suite
92-
def term_input(prompt: str) -> str:
92+
# Arguments are positional-only to match ``input``.
93+
def term_input(prompt: str, /) -> str:
9394
if sys.platform == 'win32':
9495
# Important: On windows, readline is not enabled by default. In these
9596
# environment, escape sequences have been broken. To avoid the

sphinx/events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from sphinx.config import Config
2929
from sphinx.domains import Domain
3030
from sphinx.environment import BuildEnvironment
31-
from sphinx.ext.autodoc import _AutodocProcessDocstringListener
31+
from sphinx.ext.autodoc._event_listeners import _AutodocProcessDocstringListener
3232
from sphinx.ext.todo import todo_node
3333

3434

0 commit comments

Comments
 (0)