Skip to content

Commit 097adc5

Browse files
committed
Merge branch 'master' into autosummary-short-signature
# Conflicts: # doc/usage/extensions/autosummary.rst # sphinx/ext/autosummary/__init__.py
2 parents bf01890 + 7406d42 commit 097adc5

Some content is hidden

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

61 files changed

+1016
-495
lines changed

CHANGES.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ Features added
6060
:confval:`python_trailing_comma_in_multi_line_signatures` and
6161
:confval:`javascript_trailing_comma_in_multi_line_signatures`
6262
configuration options.
63+
* #13264: Rename the :rst:dir:`math` directive's ``nowrap``option
64+
to :rst:dir:`no-wrap``,
65+
and rename the :rst:dir:`autosummary` directive's ``nosignatures``option
66+
to :rst:dir:`no-signatures``.
67+
Patch by Adam Turner.
68+
* #13269: Added the option to disable the use of type comments in
69+
via the new :confval:`autodoc_use_type_comments` option,
70+
which defaults to ``True`` for backwards compatibility.
71+
The default will change to ``False`` in Sphinx 10.
72+
Patch by Adam Turner.
6373

6474
Bugs fixed
6575
----------
@@ -92,6 +102,8 @@ Bugs fixed
92102
methods and attributes.
93103
Patch by Bénédikt Tran.
94104
* #12975: Avoid rendering a trailing comma in C and C++ multi-line signatures.
105+
* #13178: autodoc: Fix resolution for ``pathlib`` types.
106+
Patch by Adam Turner.
95107

96108
Testing
97109
-------

doc/conf.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,16 @@
187187
('py:attr', 'srcline'),
188188
('py:class', '_AutodocProcessDocstringListener'),
189189
('py:class', '_ConfigRebuild'), # sphinx.application.Sphinx.add_config_value
190+
# sphinx.application.Sphinx.add_html_math_renderer
191+
('py:class', '_MathsBlockRenderers'),
192+
# sphinx.application.Sphinx.add_html_math_renderer
193+
('py:class', '_MathsInlineRenderers'),
194+
('py:class', '_NodeHandler'), # sphinx.application.Sphinx.add_enumerable_node
195+
('py:class', '_NodeHandlerPair'), # sphinx.application.Sphinx.add_node
190196
('py:class', '_StrPath'), # sphinx.environment.BuildEnvironment.doc2path
191197
('py:class', 'Element'), # sphinx.domains.Domain
192198
('py:class', 'Documenter'), # sphinx.application.Sphinx.add_autodocumenter
199+
('py:class', 'Field'), # sphinx.application.Sphinx.add_object_type
193200
('py:class', 'IndexEntry'), # sphinx.domains.IndexEntry
194201
('py:class', 'Inliner'), # sphinx.util.docutils.SphinxRole.inliner
195202
('py:class', 'Lexer'), # sphinx.application.Sphinx.add_lexer
@@ -200,10 +207,10 @@
200207
('py:class', 'Path'), # sphinx.application.Sphinx.connect
201208
('py:class', 'RoleFunction'), # sphinx.domains.Domain
202209
('py:class', 'RSTState'), # sphinx.utils.parsing.nested_parse_to_nodes
203-
('py:class', 'Theme'), # sphinx.application.TemplateBridge
204210
('py:class', 'SearchLanguage'), # sphinx.application.Sphinx.add_search_language
205211
('py:class', 'StringList'), # sphinx.utils.parsing.nested_parse_to_nodes
206212
('py:class', 'system_message'), # sphinx.utils.docutils.SphinxDirective
213+
('py:class', 'Theme'), # sphinx.application.TemplateBridge
207214
('py:class', 'TitleGetter'), # sphinx.domains.Domain
208215
('py:class', 'todo_node'), # sphinx.application.Sphinx.connect
209216
('py:class', 'Transform'), # sphinx.application.Sphinx.add_transform

doc/man/sphinx-apidoc.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,13 @@ Options
103103

104104
.. option:: --implicit-namespaces
105105

106-
By default sphinx-apidoc processes sys.path searching for modules only.
107-
Python 3.3 introduced :pep:`420` implicit namespaces that allow module path
108-
structures such as ``foo/bar/module.py`` or ``foo/bar/baz/__init__.py``
109-
(notice that ``bar`` and ``foo`` are namespaces, not modules).
106+
Without this option, :program:`sphinx-apidoc` searches :data:`sys.path`
107+
for Python packages containing :file:`__init__.py` files,
108+
or single-file Python modules.
110109

111-
Interpret paths recursively according to PEP-0420.
110+
This option instead uses :pep:`420` implicit namespaces that allow
111+
layouts paths such as ``foo/bar/module.py`` or ``foo/bar/baz/__init__.py``
112+
(note that ``bar`` and ``foo`` are namespaces, not modules).
112113

113114
.. option:: -M, --module-first
114115

doc/usage/domains/python.rst

Lines changed: 54 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,15 @@ The following directives are provided for module and class contents:
135135
136136
This will be parsed as a Python expression for cross-referencing
137137
the type annotation.
138-
As such, the argument to ``:type:`` should be a valid Python expression.
138+
As such, the argument to ``:type:`` should be a valid `annotation expression`_.
139139
140-
.. caution:: The valid syntax for the ``:type:`` directive option
141-
differs from the syntax for the ``:type:`` `info field
142-
<info-field-lists_>`__.
140+
.. caution::
141+
The valid syntax for the ``:type:`` directive option differs from
142+
the syntax for the ``:type:`` `info field <info-field-lists_>`__.
143+
The ``:type:`` directive option does not understand
144+
reStructuredText markup or the ``or`` or ``of`` keywords,
145+
meaning unions must use ``|`` and sequences must use square brackets,
146+
and roles such as ``:ref:`...``` cannot be used.
143147
144148
.. versionadded:: 2.4
145149
@@ -277,11 +281,15 @@ The following directives are provided for module and class contents:
277281
278282
This will be parsed as a Python expression for cross-referencing
279283
the type annotation.
280-
As such, the argument to ``:type:`` should be a valid Python expression.
284+
As such, the argument to ``:type:`` should be a valid `annotation expression`_.
281285
282-
.. caution:: The valid syntax for the ``:type:`` directive option
283-
differs from the syntax for the ``:type:`` `info field
284-
<info-field-lists_>`__.
286+
.. caution::
287+
The valid syntax for the ``:type:`` directive option differs from
288+
the syntax for the ``:type:`` `info field <info-field-lists_>`__.
289+
The ``:type:`` directive option does not understand
290+
reStructuredText markup or the ``or`` or ``of`` keywords,
291+
meaning unions must use ``|`` and sequences must use square brackets,
292+
and roles such as ``:ref:`...``` cannot be used.
285293
286294
.. versionadded:: 2.4
287295
@@ -329,11 +337,15 @@ The following directives are provided for module and class contents:
329337
330338
This will be parsed as a Python expression for cross-referencing
331339
the type annotation.
332-
As such, the argument to ``:type:`` should be a valid Python expression.
340+
As such, the argument to ``:type:`` should be a valid `annotation expression`_.
333341
334-
.. caution:: The valid syntax for the ``:type:`` directive option
335-
differs from the syntax for the ``:type:`` `info field
336-
<info-field-lists_>`__.
342+
.. caution::
343+
The valid syntax for the ``:type:`` directive option differs from
344+
the syntax for the ``:type:`` `info field <info-field-lists_>`__.
345+
The ``:type:`` directive option does not understand
346+
reStructuredText markup or the ``or`` or ``of`` keywords,
347+
meaning unions must use ``|`` and sequences must use square brackets,
348+
and roles such as ``:ref:`...``` cannot be used.
337349
338350
.. rst::directive:option:: module
339351
:type: text
@@ -542,50 +554,66 @@ The following directives are provided for module and class contents:
542554

543555
Refer to a decorator method using the :rst:role:`py:meth` role.
544556

557+
.. _annotation expression: https://typing.readthedocs.io/en/latest/spec/annotations.html#type-and-annotation-expressions
558+
545559
.. _signatures:
546560

547561
Python Signatures
548562
-----------------
549563

550564
Signatures of functions, methods and class constructors can be given like they
551565
would be written in Python.
566+
This can include default values, positional-only or keyword-only parameters,
567+
type annotations, and type parameters.
568+
For example:
569+
570+
.. code-block:: rst
552571
553-
Default values for optional arguments can be given (but if they contain commas,
554-
they will confuse the signature parser). Python 3-style argument annotations
555-
can also be given as well as return type annotations::
572+
.. py:function:: compile(source: str, filename: Path, symbol: str = 'file') -> ast.AST
556573
557-
.. py:function:: compile(source : string, filename, symbol='file') -> ast object
574+
.. py:function:: compile(source: str, filename: Path, symbol: str = 'file') -> ast.AST
575+
:no-index:
558576

559577
For functions with optional parameters that don't have default values
560578
(typically functions implemented in C extension modules without keyword
561-
argument support), you can use brackets to specify the optional parts:
579+
argument support),
580+
you can list multiple versions of the same signature in a single directive:
562581

563-
.. py:function:: compile(source[, filename[, symbol]])
564-
:no-contents-entry:
565-
:no-index-entry:
582+
.. py:function:: compile(source)
583+
compile(source, filename)
584+
compile(source, filename, symbol)
585+
:no-index:
586+
587+
Another approach is to use square brackets to specify the optional parts.
588+
When using square brackets, it is customary to place
589+
the opening bracket before the comma (``[,``).
566590

567-
It is customary to put the opening bracket before the comma.
591+
.. py:function:: compile(source[, filename[, symbol]])
592+
:no-index:
568593

569594
Python 3.12 introduced *type parameters*, which are type variables
570-
declared directly within the class or function definition:
595+
declared directly within the class or function definition:
571596

572597
.. code-block:: python
573598
574599
class AnimalList[AnimalT](list[AnimalT]):
575-
...
600+
...
576601
577602
def add[T](a: T, b: T) -> T:
578-
return a + b
603+
return a + b
579604
580-
The corresponding reStructuredText documentation would be:
605+
The corresponding reStructuredText markup would be:
581606

582607
.. code-block:: rst
583608
584609
.. py:class:: AnimalList[AnimalT]
585610
586611
.. py:function:: add[T](a: T, b: T) -> T
587612
588-
See :pep:`695` and :pep:`696` for details and the full specification.
613+
.. seealso::
614+
615+
:pep:`695` and :pep:`696`, for details and the full specification.
616+
589617

590618
.. _info-field-lists:
591619

doc/usage/extensions/autodoc.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,26 @@ There are also config values that you can set:
12301230
Added as an experimental feature. This will be integrated into autodoc core
12311231
in the future.
12321232

1233+
.. confval:: autodoc_use_type_comments
1234+
:type: :code-py:`bool`
1235+
:default: :code-py:`True`
1236+
1237+
Attempt to read ``# type: ...`` comments from source code
1238+
to supplement missing type annotations, if True.
1239+
1240+
This can be disabled if your source code does not use type comments,
1241+
for example if it exclusively uses type annotations or
1242+
does not use type hints of any kind.
1243+
1244+
.. versionadded:: 8.2
1245+
1246+
Added the option to disable the use of type comments in
1247+
via the new :confval:`!autodoc_use_type_comments` option,
1248+
which defaults to :code-py:`True` for backwards compatibility.
1249+
The default will change to :code-py:`False` in Sphinx 10.
1250+
1251+
.. xref RemovedInSphinx10Warning
1252+
12331253
.. confval:: autodoc_warningiserror
12341254
:type: :code-py:`bool`
12351255
:default: :code-py:`True`

doc/usage/extensions/autosummary.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,22 @@ The :mod:`sphinx.ext.autosummary` extension does this in two parts:
115115
.. versionadded:: 8.2
116116
117117
.. rst:directive:option:: nosignatures
118+
.. rst:directive:option:: no-signatures
118119
119120
Do not show function signatures in the summary.
120121
121122
This is equivalent to ``:signatures: none``.
122123
123124
.. versionadded:: 0.6
124125
126+
.. versionchanged:: 8.2
127+
128+
The directive option ``:nosignatures:`` was renamed to ``:no-signatures:``.
129+
130+
The previous name has been retained as an alias,
131+
but will be deprecated and removed
132+
in a future version of Sphinx.
133+
125134
.. rst:directive:option:: template: filename
126135
127136
Specify a custom template for rendering the summary.

doc/usage/extensions/intersphinx.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,12 @@ Showing all links of an Intersphinx mapping file
220220
------------------------------------------------
221221

222222
To show all Intersphinx links and their targets of an Intersphinx mapping file,
223-
run ``python -msphinx.ext.intersphinx url-or-path``. This is helpful when
223+
run ``python -m sphinx.ext.intersphinx url-or-path``. This is helpful when
224224
searching for the root cause of a broken Intersphinx link in a documentation
225-
project. The following example prints the Intersphinx mapping of the Python 3
226-
documentation::
225+
project.
226+
The following example prints the Intersphinx mapping of the Python documentation:
227+
228+
.. code-block:: console
227229
228230
$ python -m sphinx.ext.intersphinx https://docs.python.org/3/objects.inv
229231

0 commit comments

Comments
 (0)