Skip to content

Commit f3a098d

Browse files
authored
Merge branch '4.x' into 9194_Literal_type_not_hyperlinked
2 parents 7da4299 + 31ed71d commit f3a098d

File tree

135 files changed

+4750
-4728
lines changed

Some content is hidden

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

135 files changed

+4750
-4728
lines changed

CHANGES

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ Release 4.4.0 (in development)
44
Dependencies
55
------------
66

7+
* #10007: Use ``importlib_metadata`` for python-3.9 or older
8+
* #10007: Drop ``setuptools``
9+
710
Incompatible changes
811
--------------------
912

@@ -13,7 +16,7 @@ Deprecated
1316
Features added
1417
--------------
1518

16-
* #9075: autodoc: Add a config variable :confval:`autodoc_unqualified_typehints`
19+
* #9075: autodoc: Add a config variable :confval:`autodoc_typehints_format`
1720
to suppress the leading module names of typehints of function signatures (ex.
1821
``io.StringIO`` -> ``StringIO``)
1922
* #9831: Autosummary now documents only the members specified in a module's

doc/usage/extensions/autodoc.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -662,10 +662,15 @@ There are also config values that you can set:
662662
.. __: https://mypy.readthedocs.io/en/latest/kinds_of_types.html#type-aliases
663663
.. versionadded:: 3.3
664664

665-
.. confval:: autodoc_unqualified_typehints
665+
.. confval:: autodoc_typehints_format
666666

667-
If True, the leading module names of typehints of function signatures are
668-
removed (ex. ``io.StringIO`` -> ``StringIO``). Defaults to False.
667+
This value controls the format of typehints. The setting takes the
668+
following values:
669+
670+
* ``'fully-qualified'`` -- Show the module name and its name of typehints
671+
(default)
672+
* ``'short'`` -- Suppress the leading module names of the typehints
673+
(ex. ``io.StringIO`` -> ``StringIO``)
669674

670675
.. versionadded:: 4.4
671676

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
'alabaster>=0.7,<0.8',
3030
'imagesize',
3131
'requests>=2.5.0',
32-
'setuptools',
3332
'packaging',
33+
"importlib-metadata>=4.4; python_version < '3.10'",
3434
]
3535

3636
extras_require = {
@@ -47,7 +47,6 @@
4747
'mypy>=0.930',
4848
'docutils-stubs',
4949
"types-typed-ast",
50-
"types-pkg_resources",
5150
"types-requests",
5251
],
5352
'test': [

sphinx/application.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -933,14 +933,18 @@ def add_post_transform(self, transform: Type[Transform]) -> None:
933933
def add_js_file(self, filename: str, priority: int = 500, **kwargs: Any) -> None:
934934
"""Register a JavaScript file to include in the HTML output.
935935
936-
Add *filename* to the list of JavaScript files that the default HTML
937-
template will include in order of *priority* (ascending). The filename
938-
must be relative to the HTML static path , or a full URI with scheme.
939-
If the priority of the JavaScript file is the same as others, the JavaScript
940-
files will be included in order of registration. If the keyword
941-
argument ``body`` is given, its value will be added between the
942-
``<script>`` tags. Extra keyword arguments are included as attributes of
943-
the ``<script>`` tag.
936+
:param filename: The filename of the JavaScript file. It must be relative to the HTML
937+
static path, a full URI with scheme, or ``None`` value. The ``None``
938+
value is used to create inline ``<script>`` tag. See the description
939+
of *kwargs* below.
940+
:param priority: The priority to determine the order of ``<script>`` tag for
941+
JavaScript files. See list of "prority range for JavaScript
942+
files" below. If the priority of the JavaScript files it the same
943+
as others, the JavaScript files will be loaded in order of
944+
registration.
945+
:param kwargs: Extra keyword arguments are included as attributes of the ``<script>``
946+
tag. A special keyword argument ``body`` is given, its value will be
947+
added between the ``<script>`` tag.
944948
945949
Example::
946950
@@ -984,12 +988,14 @@ def add_js_file(self, filename: str, priority: int = 500, **kwargs: Any) -> None
984988
def add_css_file(self, filename: str, priority: int = 500, **kwargs: Any) -> None:
985989
"""Register a stylesheet to include in the HTML output.
986990
987-
Add *filename* to the list of CSS files that the default HTML template
988-
will include in order of *priority* (ascending). The filename must be
989-
relative to the HTML static path, or a full URI with scheme. If the
990-
priority of the CSS file is the same as others, the CSS files will be
991-
included in order of registration. The keyword arguments are also
992-
accepted for attributes of ``<link>`` tag.
991+
:param filename: The filename of the CSS file. It must be relative to the HTML
992+
static path, or a full URI with scheme.
993+
:param priority: The priority to determine the order of ``<link>`` tag for the
994+
CSS files. See list of "prority range for CSS files" below.
995+
If the priority of the CSS files it the same as others, the
996+
CSS files will be loaded in order of registration.
997+
:param kwargs: Extra keyword arguments are included as attributes of the ``<link>``
998+
tag.
993999
9941000
Example::
9951001

sphinx/ext/autodoc/__init__.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ def can_document_member(cls, member: Any, membername: str, isattr: bool, parent:
12951295
def format_args(self, **kwargs: Any) -> str:
12961296
if self.config.autodoc_typehints in ('none', 'description'):
12971297
kwargs.setdefault('show_annotation', False)
1298-
if self.config.autodoc_unqualified_typehints:
1298+
if self.config.autodoc_typehints_format == "short":
12991299
kwargs.setdefault('unqualified_typehints', True)
13001300

13011301
try:
@@ -1325,7 +1325,7 @@ def add_directive_header(self, sig: str) -> None:
13251325
self.add_line(' :async:', sourcename)
13261326

13271327
def format_signature(self, **kwargs: Any) -> str:
1328-
if self.config.autodoc_unqualified_typehints:
1328+
if self.config.autodoc_typehints_format == "short":
13291329
kwargs.setdefault('unqualified_typehints', True)
13301330

13311331
sigs = []
@@ -1566,7 +1566,7 @@ def get_user_defined_function_or_method(obj: Any, attr: str) -> Any:
15661566
def format_args(self, **kwargs: Any) -> str:
15671567
if self.config.autodoc_typehints in ('none', 'description'):
15681568
kwargs.setdefault('show_annotation', False)
1569-
if self.config.autodoc_unqualified_typehints:
1569+
if self.config.autodoc_typehints_format == "short":
15701570
kwargs.setdefault('unqualified_typehints', True)
15711571

15721572
try:
@@ -1589,7 +1589,7 @@ def format_signature(self, **kwargs: Any) -> str:
15891589
# do not show signatures
15901590
return ''
15911591

1592-
if self.config.autodoc_unqualified_typehints:
1592+
if self.config.autodoc_typehints_format == "short":
15931593
kwargs.setdefault('unqualified_typehints', True)
15941594

15951595
sig = super().format_signature()
@@ -2120,7 +2120,7 @@ def import_object(self, raiseerror: bool = False) -> bool:
21202120
def format_args(self, **kwargs: Any) -> str:
21212121
if self.config.autodoc_typehints in ('none', 'description'):
21222122
kwargs.setdefault('show_annotation', False)
2123-
if self.config.autodoc_unqualified_typehints:
2123+
if self.config.autodoc_typehints_format == "short":
21242124
kwargs.setdefault('unqualified_typehints', True)
21252125

21262126
try:
@@ -2172,7 +2172,7 @@ def document_members(self, all_members: bool = False) -> None:
21722172
pass
21732173

21742174
def format_signature(self, **kwargs: Any) -> str:
2175-
if self.config.autodoc_unqualified_typehints:
2175+
if self.config.autodoc_typehints_format == "short":
21762176
kwargs.setdefault('unqualified_typehints', True)
21772177

21782178
sigs = []
@@ -2848,7 +2848,8 @@ def setup(app: Sphinx) -> Dict[str, Any]:
28482848
app.add_config_value('autodoc_typehints_description_target', 'all', True,
28492849
ENUM('all', 'documented'))
28502850
app.add_config_value('autodoc_type_aliases', {}, True)
2851-
app.add_config_value('autodoc_unqualified_typehints', False, 'env')
2851+
app.add_config_value('autodoc_typehints_format', "fully-qualified", 'env',
2852+
ENUM("fully-qualified", "short"))
28522853
app.add_config_value('autodoc_warningiserror', True, True)
28532854
app.add_config_value('autodoc_inherit_docstrings', True, True)
28542855
app.add_event('autodoc-before-process-signature')

sphinx/locale/.tx/config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ host = https://www.transifex.com
55
file_filter = <lang>/LC_MESSAGES/sphinx.po
66
source_file = sphinx.pot
77
source_lang = en
8-
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)