Skip to content

Commit 38d5d76

Browse files
Merge branch 'master' into dependabot/pip/mypy-1.16.1
2 parents 78f0b99 + 7551ef5 commit 38d5d76

39 files changed

+637
-375
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ tests/roots/test-pycode/cp_1251_coded.py dos
5151

5252
# Non UTF-8 encodings
5353
tests/roots/test-pycode/cp_1251_coded.py working-tree-encoding=windows-1251
54+
tests/roots/test-root/wrongenc.inc working-tree-encoding=latin-1
55+
tests/roots/test-warnings/wrongenc.inc working-tree-encoding=latin-1
5456

5557
# Generated files
5658
# https://github.com/github/linguist/blob/master/docs/overrides.md

CHANGES.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ Deprecated
2626
* #13665: Deprecate support for non-UTF 8 source encodings,
2727
scheduled for removal in Sphinx 10.
2828
Patch by Adam Turner.
29+
* #13679: Non-decodable characters in source files will raise an error in Sphinx 9.
30+
Currently, such bytes are replaced with '?' along with logging a warning.
31+
Patch by Adam Turner.
32+
* #13682: Deprecate :py:mod:`!sphinx.io`.
33+
Sphinx no longer uses the :py:mod:`!sphinx.io` classes,
34+
having replaced them with standard Python I/O.
35+
The entire :py:mod:`!sphinx.io` module will be removed in Sphinx 10.
36+
Patch by Adam Turner.
2937

3038
Features added
3139
--------------
@@ -46,10 +54,18 @@ Features added
4654
Patch by Adam Turner.
4755
* #13647: LaTeX: allow more cases of table nesting.
4856
Patch by Jean-François B.
57+
* #13684: intersphinx: Add a file-based cache for remote inventories.
58+
The location of the cache directory must not be relied upon externally,
59+
as it may change without notice or warning in future releases.
60+
Patch by Adam Turner.
4961

5062
Bugs fixed
5163
----------
5264

65+
* #11498: LaTeX: Table in cell fails to build if it has many rows.
66+
Patch by Jean-François B.
67+
* #11515: LaTeX: longtable does not allow nested table.
68+
Patch by Jean-François B.
5369
* #12821: LaTeX: URLs/links in section titles should render in PDF.
5470
Patch by Jean-François B.
5571
* #13369: Correctly parse and cross-reference unpacked type annotations.
@@ -65,6 +81,8 @@ Bugs fixed
6581
* #13635: LaTeX: if a cell contains a table, row coloring is turned off for
6682
the next table cells.
6783
Patch by Jean-François B.
84+
* #13685: gettext: Correctly ignore trailing backslashes.
85+
Patch by Bénédikt Tran.
6886

6987
Testing
7088
-------

doc/extdev/deprecated.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ The following is a list of deprecated interfaces.
2222
- Removed
2323
- Alternatives
2424

25+
* - ``sphinx.io`` (entire module)
26+
- 8.3
27+
- 10.0
28+
- ``docutils.io`` or standard Python I/O
29+
2530
* - ``sphinx.builders.Builder.app``
2631
- 8.3
2732
- 10.0

doc/usage/domains/index.rst

Lines changed: 63 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,69 @@ easier to write.
3535
This section describes what the domains that are included with Sphinx provide.
3636
The domain API is documented as well, in the section :ref:`domain-api`.
3737

38+
Built-in domains
39+
----------------
40+
41+
The following domains are included within Sphinx:
42+
43+
.. toctree::
44+
:maxdepth: 1
45+
46+
standard
47+
c
48+
cpp
49+
javascript
50+
mathematics
51+
python
52+
restructuredtext
53+
54+
55+
Third-party domains
56+
-------------------
57+
58+
Several third-party domains are available as extensions, including:
59+
60+
* `Ada <https://pypi.org/project/sphinxcontrib-adadomain/>`__
61+
* `Antlr4 <https://pypi.org/project/sphinx-a4doc/>`__
62+
* `Bazel <https://pypi.org/project/sphinx-bazel/>`__
63+
* `BibTex <https://pypi.org/project/sphinxcontrib-bibtex/>`__
64+
* `Chapel <https://pypi.org/project/sphinxcontrib-chapeldomain/>`__
65+
* `CMake <https://pypi.org/project/sphinxcontrib-moderncmakedomain/>`__
66+
* `Common Lisp <https://pypi.org/project/sphinxcontrib-cldomain/>`__
67+
* `Erlang <https://pypi.org/project/sphinxcontrib-erlangdomain/>`__
68+
* `Fortran <https://pypi.org/project/sphinx-fortran/>`__
69+
* `GraphQL <https://pypi.org/project/graphqldomain/>`__
70+
* `Go <https://pypi.org/project/sphinxcontrib-golangdomain/>`__
71+
* `HTTP <https://pypi.org/project/sphinxcontrib-httpdomain/>`__
72+
* `Hy <https://pypi.org/project/sphinxcontrib-hydomain/>`__
73+
* `Lua <https://pypi.org/project/sphinxcontrib-luadomain/>`__
74+
* `MATLAB <https://pypi.org/project/sphinxcontrib-matlabdomain/>`__
75+
* `PHP <https://pypi.org/project/sphinxcontrib-phpdomain/>`__
76+
* `Ruby <https://pypi.org/project/sphinxcontrib-rubydomain/>`__
77+
* `Rust <https://pypi.org/project/sphinxcontrib-rust/>`__
78+
* `Verilog <https://pypi.org/project/sphinx-verilog-domain/>`__
79+
* `VHDL <https://pypi.org/project/sphinx-vhdl/>`__
80+
* `Visual Basic <https://pypi.org/project/sphinx-vb-domain/>`__
81+
82+
Other domains may be found on the Python Package Index
83+
(via the `Framework :: Sphinx :: Domain`__ classifier),
84+
`GitHub <https://github.com/search?q=sphinx%20domain&type=repositories>`__, or
85+
`GitLab <https://gitlab.com/explore/projects?name=sphinx%20domain>`__.
86+
87+
__ https://pypi.org/search/?c=Framework+%3A%3A+Sphinx+%3A%3A+Domain
88+
89+
.. NOTE: The following all seem unmaintained, last released 2018 or earlier.
90+
The links are preserved in this comment for reference.
91+
92+
* `CoffeeScript <https://pypi.org/project/sphinxcontrib-coffee/>`__
93+
* `DotNET <https://pypi.org/project/sphinxcontrib-dotnetdomain/>`__
94+
* `dqn <https://pypi.org/project/sphinxcontrib-dqndomain/>`__
95+
* `Jinja <https://pypi.org/project/sphinxcontrib-jinjadomain/>`__
96+
* `JSON <https://pypi.org/project/sphinx-jsondomain/>`__
97+
* `Lasso <https://pypi.org/project/sphinxcontrib-lassodomain/>`__
98+
* `Operation <https://pypi.org/project/sphinxcontrib-operationdomain/>`__
99+
* `Scala <https://pypi.org/project/sphinxcontrib-scaladomain/>`__
100+
38101
39102
.. _basic-domain-markup:
40103

@@ -174,40 +237,3 @@ In short:
174237
component of the target.
175238
For example, ``:py:meth:`~queue.Queue.get``` will
176239
refer to ``queue.Queue.get`` but only display ``get`` as the link text.
177-
178-
Built-in domains
179-
----------------
180-
181-
The following domains are included within Sphinx:
182-
183-
.. toctree::
184-
:maxdepth: 1
185-
186-
standard
187-
c
188-
cpp
189-
javascript
190-
mathematics
191-
python
192-
restructuredtext
193-
194-
More domains
195-
------------
196-
197-
There are several third-party domains available as extensions, including:
198-
199-
* `Ada <https://pypi.org/project/sphinxcontrib-adadomain/>`__
200-
* `Chapel <https://pypi.org/project/sphinxcontrib-chapeldomain/>`__
201-
* `CoffeeScript <https://pypi.org/project/sphinxcontrib-coffee/>`__
202-
* `Common Lisp <https://pypi.org/project/sphinxcontrib-cldomain/>`__
203-
* `dqn <https://pypi.org/project/sphinxcontrib-dqndomain/>`__
204-
* `Erlang <https://pypi.org/project/sphinxcontrib-erlangdomain/>`__
205-
* `Go <https://pypi.org/project/sphinxcontrib-golangdomain/>`__
206-
* `HTTP <https://pypi.org/project/sphinxcontrib-httpdomain/>`__
207-
* `Jinja <https://pypi.org/project/sphinxcontrib-jinjadomain/>`__
208-
* `Lasso <https://pypi.org/project/sphinxcontrib-lassodomain/>`__
209-
* `MATLAB <https://pypi.org/project/sphinxcontrib-matlabdomain/>`__
210-
* `Operation <https://pypi.org/project/sphinxcontrib-operationdomain/>`__
211-
* `PHP <https://pypi.org/project/sphinxcontrib-phpdomain/>`__
212-
* `Ruby <https://pypi.org/project/sphinxcontrib-rubydomain/>`__
213-
* `Scala <https://pypi.org/project/sphinxcontrib-scaladomain/>`__

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@ module = [
304304
# tests/test_config
305305
"tests.test_config.test_config",
306306
# tests/test_directives
307-
"tests.test_directives.test_directive_only",
308307
"tests.test_directives.test_directive_other",
309308
"tests.test_directives.test_directive_patch",
310309
# tests/test_domains

sphinx/builders/__init__.py

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from typing import TYPE_CHECKING, final
1212

1313
from docutils import nodes
14-
from docutils.utils import DependencyList
1514

1615
from sphinx._cli.util.colour import bold
1716
from sphinx.deprecation import _deprecation_warning
@@ -23,16 +22,12 @@
2322
from sphinx.environment.adapters.asset import ImageAdapter
2423
from sphinx.errors import SphinxError
2524
from sphinx.locale import __
26-
from sphinx.util import (
27-
get_filetype,
28-
logging,
29-
rst,
30-
)
25+
from sphinx.util import get_filetype, logging
3126
from sphinx.util._importer import import_object
3227
from sphinx.util._pathlib import _StrPathProperty
3328
from sphinx.util.build_phase import BuildPhase
3429
from sphinx.util.display import progress_message, status_iterator
35-
from sphinx.util.docutils import sphinx_domains
30+
from sphinx.util.docutils import _parse_str_to_doctree
3631
from sphinx.util.i18n import CatalogRepository, docname_to_domain
3732
from sphinx.util.osutil import ensuredir, relative_uri, relpath
3833
from sphinx.util.parallel import (
@@ -644,26 +639,34 @@ def read_doc(self, docname: str, *, _cache: bool = True) -> None:
644639
if docutils_conf.is_file():
645640
env.note_dependency(docutils_conf)
646641

647-
filename = str(env.doc2path(docname))
648-
filetype = get_filetype(self._app.config.source_suffix, filename)
649-
publisher = self._registry._get_publisher(
650-
filetype, config=self.config, env=self.env
642+
filename = env.doc2path(docname)
643+
644+
# set up error_handler for the target document
645+
# xref RemovedInSphinx90Warning
646+
error_handler = _UnicodeDecodeErrorHandler(docname)
647+
codecs.register_error('sphinx', error_handler) # type: ignore[arg-type]
648+
649+
# read the source file
650+
content = filename.read_text(
651+
encoding=env.settings['input_encoding'], errors='sphinx'
651652
)
652-
self.env.current_document._parser = publisher.parser
653-
# record_dependencies is mutable even though it is in settings,
654-
# explicitly re-initialise for each document
655-
publisher.settings.record_dependencies = DependencyList()
656-
with (
657-
sphinx_domains(env),
658-
rst.default_role(docname, self.config.default_role),
659-
):
660-
# set up error_handler for the target document
661-
error_handler = _UnicodeDecodeErrorHandler(docname)
662-
codecs.register_error('sphinx', error_handler) # type: ignore[arg-type]
663653

664-
publisher.set_source(source_path=filename)
665-
publisher.publish()
666-
doctree = publisher.document
654+
# TODO: move the "source-read" event to here.
655+
656+
filetype = get_filetype(self.config.source_suffix, filename)
657+
parser = self._registry.create_source_parser(
658+
filetype, config=self.config, env=env
659+
)
660+
doctree = _parse_str_to_doctree(
661+
content,
662+
filename=filename,
663+
default_role=self.config.default_role,
664+
default_settings=env.settings,
665+
env=env,
666+
events=self.events,
667+
parser=parser,
668+
transforms=self._registry.get_transforms(),
669+
)
667670

668671
# store time of reading, for outdated files detection
669672
env.all_docs[docname] = time.time_ns() // 1_000
@@ -901,20 +904,21 @@ def __init__(self, docname: str, /) -> None:
901904
self.docname = docname
902905

903906
def __call__(self, error: UnicodeDecodeError) -> tuple[str, int]:
904-
line_start = error.object.rfind(b'\n', 0, error.start)
905-
line_end = error.object.find(b'\n', error.start)
907+
obj = error.object
908+
line_start = obj.rfind(b'\n', 0, error.start)
909+
line_end = obj.find(b'\n', error.start)
906910
if line_end == -1:
907-
line_end = len(error.object)
908-
line_num = error.object.count(b'\n', 0, error.start) + 1
911+
line_end = len(obj)
912+
line_num = obj.count(b'\n', 0, error.start) + 1
909913
logger.warning(
910-
__('undecodable source characters, replacing with "?": %r'),
911-
(
912-
error.object[line_start + 1 : error.start]
913-
+ b'>>>'
914-
+ error.object[error.start : error.end]
915-
+ b'<<<'
916-
+ error.object[error.end : line_end]
914+
__(
915+
"undecodable source characters, replacing with '?': '%s>>>%s<<<%s'. "
916+
'This will become an error in Sphinx 9.0.'
917+
# xref RemovedInSphinx90Warning
917918
),
919+
obj[line_start + 1 : error.start].decode(errors='backslashreplace'),
920+
obj[error.start : error.end].decode(errors='backslashreplace'),
921+
obj[error.end : line_end].decode(errors='backslashreplace'),
918922
location=(self.docname, line_num),
919923
)
920924
return '?', error.end

0 commit comments

Comments
 (0)