summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-04-18 14:54:54 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2021-04-19 01:11:08 +0900
commit58ec5c4089a6aaa1c638741b8ebe38f627e0c1d1 (patch)
treebb6d9869407747239cb561b4ce782133cf44fbba
parent9105635389e917804897e743fa639cbcbb394453 (diff)
downloadsphinx-git-58ec5c4089a6aaa1c638741b8ebe38f627e0c1d1.tar.gz
Fix #9110: autodoc: metadata of GenericAlias is not rendered as a reference in py37+
GenericAliasMixin should use `restify()` to render the metadata of GenericAlias as py36 does.
-rw-r--r--CHANGES2
-rw-r--r--sphinx/ext/autodoc/__init__.py3
-rw-r--r--tests/test_ext_autodoc.py4
-rw-r--r--tests/test_ext_autodoc_autoattribute.py2
-rw-r--r--tests/test_ext_autodoc_autodata.py2
5 files changed, 7 insertions, 6 deletions
diff --git a/CHANGES b/CHANGES
index 929638388..f18c806e0 100644
--- a/CHANGES
+++ b/CHANGES
@@ -17,6 +17,8 @@ Features added
--------------
* #8818: autodoc: Super class having ``Any`` arguments causes nit-picky warning
+* #9110: autodoc: metadata of GenericAlias is not rendered as a reference in
+ py37+
* #9103: LaTeX: imgconverter: conversion runs even if not needed
* #8127: py domain: Ellipsis in info-field-list causes nit-picky warning
* #9023: More CSS classes on domain descriptions, see :ref:`nodes` for details.
diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py
index 5a0a8ca10..c92709deb 100644
--- a/sphinx/ext/autodoc/__init__.py
+++ b/sphinx/ext/autodoc/__init__.py
@@ -1767,8 +1767,7 @@ class GenericAliasMixin(DataDocumenterMixinBase):
def update_content(self, more_content: StringList) -> None:
if inspect.isgenericalias(self.object):
- alias = stringify_typehint(self.object)
- more_content.append(_('alias of %s') % alias, '')
+ more_content.append(_('alias of %s') % restify(self.object), '')
more_content.append('', '')
super().update_content(more_content)
diff --git a/tests/test_ext_autodoc.py b/tests/test_ext_autodoc.py
index ccdee6bb2..2becf5de2 100644
--- a/tests/test_ext_autodoc.py
+++ b/tests/test_ext_autodoc.py
@@ -1915,7 +1915,7 @@ def test_autodoc_GenericAlias(app):
'',
' A list of int',
'',
- ' alias of List[int]',
+ ' alias of :class:`~typing.List`\\ [:class:`int`]',
'',
'',
'.. py:data:: T',
@@ -1923,7 +1923,7 @@ def test_autodoc_GenericAlias(app):
'',
' A list of int',
'',
- ' alias of List[int]',
+ ' alias of :class:`~typing.List`\\ [:class:`int`]',
'',
]
diff --git a/tests/test_ext_autodoc_autoattribute.py b/tests/test_ext_autodoc_autoattribute.py
index 48e897b2e..5e7220234 100644
--- a/tests/test_ext_autodoc_autoattribute.py
+++ b/tests/test_ext_autodoc_autoattribute.py
@@ -156,7 +156,7 @@ def test_autoattribute_GenericAlias(app):
'',
' A list of int',
'',
- ' alias of List[int]',
+ ' alias of :class:`~typing.List`\\ [:class:`int`]',
'',
]
diff --git a/tests/test_ext_autodoc_autodata.py b/tests/test_ext_autodoc_autodata.py
index 907d70aa1..d01e45fc1 100644
--- a/tests/test_ext_autodoc_autodata.py
+++ b/tests/test_ext_autodoc_autodata.py
@@ -96,7 +96,7 @@ def test_autodata_GenericAlias(app):
'',
' A list of int',
'',
- ' alias of List[int]',
+ ' alias of :class:`~typing.List`\\ [:class:`int`]',
'',
]