Skip to content

Commit

Permalink
Merge branch '4.x' into 9194_Literal_type_not_hyperlinked
Browse files Browse the repository at this point in the history
  • Loading branch information
tk0miya committed Dec 26, 2021
2 parents 7da4299 + 31ed71d commit f3a098d
Show file tree
Hide file tree
Showing 135 changed files with 4,750 additions and 4,728 deletions.
5 changes: 4 additions & 1 deletion CHANGES
Expand Up @@ -4,6 +4,9 @@ Release 4.4.0 (in development)
Dependencies
------------

* #10007: Use ``importlib_metadata`` for python-3.9 or older
* #10007: Drop ``setuptools``

Incompatible changes
--------------------

Expand All @@ -13,7 +16,7 @@ Deprecated
Features added
--------------

* #9075: autodoc: Add a config variable :confval:`autodoc_unqualified_typehints`
* #9075: autodoc: Add a config variable :confval:`autodoc_typehints_format`
to suppress the leading module names of typehints of function signatures (ex.
``io.StringIO`` -> ``StringIO``)
* #9831: Autosummary now documents only the members specified in a module's
Expand Down
11 changes: 8 additions & 3 deletions doc/usage/extensions/autodoc.rst
Expand Up @@ -662,10 +662,15 @@ There are also config values that you can set:
.. __: https://mypy.readthedocs.io/en/latest/kinds_of_types.html#type-aliases
.. versionadded:: 3.3

.. confval:: autodoc_unqualified_typehints
.. confval:: autodoc_typehints_format

If True, the leading module names of typehints of function signatures are
removed (ex. ``io.StringIO`` -> ``StringIO``). Defaults to False.
This value controls the format of typehints. The setting takes the
following values:

* ``'fully-qualified'`` -- Show the module name and its name of typehints
(default)
* ``'short'`` -- Suppress the leading module names of the typehints
(ex. ``io.StringIO`` -> ``StringIO``)

.. versionadded:: 4.4

Expand Down
3 changes: 1 addition & 2 deletions setup.py
Expand Up @@ -29,8 +29,8 @@
'alabaster>=0.7,<0.8',
'imagesize',
'requests>=2.5.0',
'setuptools',
'packaging',
"importlib-metadata>=4.4; python_version < '3.10'",
]

extras_require = {
Expand All @@ -47,7 +47,6 @@
'mypy>=0.930',
'docutils-stubs',
"types-typed-ast",
"types-pkg_resources",
"types-requests",
],
'test': [
Expand Down
34 changes: 20 additions & 14 deletions sphinx/application.py
Expand Up @@ -933,14 +933,18 @@ def add_post_transform(self, transform: Type[Transform]) -> None:
def add_js_file(self, filename: str, priority: int = 500, **kwargs: Any) -> None:
"""Register a JavaScript file to include in the HTML output.
Add *filename* to the list of JavaScript files that the default HTML
template will include in order of *priority* (ascending). The filename
must be relative to the HTML static path , or a full URI with scheme.
If the priority of the JavaScript file is the same as others, the JavaScript
files will be included in order of registration. If the keyword
argument ``body`` is given, its value will be added between the
``<script>`` tags. Extra keyword arguments are included as attributes of
the ``<script>`` tag.
:param filename: The filename of the JavaScript file. It must be relative to the HTML
static path, a full URI with scheme, or ``None`` value. The ``None``
value is used to create inline ``<script>`` tag. See the description
of *kwargs* below.
:param priority: The priority to determine the order of ``<script>`` tag for
JavaScript files. See list of "prority range for JavaScript
files" below. If the priority of the JavaScript files it the same
as others, the JavaScript files will be loaded in order of
registration.
:param kwargs: Extra keyword arguments are included as attributes of the ``<script>``
tag. A special keyword argument ``body`` is given, its value will be
added between the ``<script>`` tag.
Example::
Expand Down Expand Up @@ -984,12 +988,14 @@ def add_js_file(self, filename: str, priority: int = 500, **kwargs: Any) -> None
def add_css_file(self, filename: str, priority: int = 500, **kwargs: Any) -> None:
"""Register a stylesheet to include in the HTML output.
Add *filename* to the list of CSS files that the default HTML template
will include in order of *priority* (ascending). The filename must be
relative to the HTML static path, or a full URI with scheme. If the
priority of the CSS file is the same as others, the CSS files will be
included in order of registration. The keyword arguments are also
accepted for attributes of ``<link>`` tag.
:param filename: The filename of the CSS file. It must be relative to the HTML
static path, or a full URI with scheme.
:param priority: The priority to determine the order of ``<link>`` tag for the
CSS files. See list of "prority range for CSS files" below.
If the priority of the CSS files it the same as others, the
CSS files will be loaded in order of registration.
:param kwargs: Extra keyword arguments are included as attributes of the ``<link>``
tag.
Example::
Expand Down
15 changes: 8 additions & 7 deletions sphinx/ext/autodoc/__init__.py
Expand Up @@ -1295,7 +1295,7 @@ def can_document_member(cls, member: Any, membername: str, isattr: bool, parent:
def format_args(self, **kwargs: Any) -> str:
if self.config.autodoc_typehints in ('none', 'description'):
kwargs.setdefault('show_annotation', False)
if self.config.autodoc_unqualified_typehints:
if self.config.autodoc_typehints_format == "short":
kwargs.setdefault('unqualified_typehints', True)

try:
Expand Down Expand Up @@ -1325,7 +1325,7 @@ def add_directive_header(self, sig: str) -> None:
self.add_line(' :async:', sourcename)

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

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

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

if self.config.autodoc_unqualified_typehints:
if self.config.autodoc_typehints_format == "short":
kwargs.setdefault('unqualified_typehints', True)

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

try:
Expand Down Expand Up @@ -2172,7 +2172,7 @@ def document_members(self, all_members: bool = False) -> None:
pass

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

sigs = []
Expand Down Expand Up @@ -2848,7 +2848,8 @@ def setup(app: Sphinx) -> Dict[str, Any]:
app.add_config_value('autodoc_typehints_description_target', 'all', True,
ENUM('all', 'documented'))
app.add_config_value('autodoc_type_aliases', {}, True)
app.add_config_value('autodoc_unqualified_typehints', False, 'env')
app.add_config_value('autodoc_typehints_format', "fully-qualified", 'env',
ENUM("fully-qualified", "short"))
app.add_config_value('autodoc_warningiserror', True, True)
app.add_config_value('autodoc_inherit_docstrings', True, True)
app.add_event('autodoc-before-process-signature')
Expand Down
1 change: 0 additions & 1 deletion sphinx/locale/.tx/config
Expand Up @@ -5,4 +5,3 @@ host = https://www.transifex.com
file_filter = <lang>/LC_MESSAGES/sphinx.po
source_file = sphinx.pot
source_lang = en

Binary file modified sphinx/locale/ar/LC_MESSAGES/sphinx.mo
Binary file not shown.

0 comments on commit f3a098d

Please sign in to comment.