summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-11-21 19:55:45 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-11-22 13:57:48 +0900
commit9eb96d5c793280f5cef932f012cb38a67393af11 (patch)
treeefc06c29d568a24ffc45c21bc8f03099f7518984 /tests
parent24a329eebe3a53c26955d89e67118f2652988eff (diff)
downloadsphinx-git-9eb96d5c793280f5cef932f012cb38a67393af11.tar.gz
Fix #8460: autodata directive does not display the detail of TypeVars
The details are only shown when automodule directive is used. This allows to document them via other auto* directives.
Diffstat (limited to 'tests')
-rw-r--r--tests/roots/test-ext-autodoc/target/typevar.py3
-rw-r--r--tests/test_ext_autodoc.py12
-rw-r--r--tests/test_ext_autodoc_autoattribute.py15
-rw-r--r--tests/test_ext_autodoc_autodata.py15
4 files changed, 44 insertions, 1 deletions
diff --git a/tests/roots/test-ext-autodoc/target/typevar.py b/tests/roots/test-ext-autodoc/target/typevar.py
index ce531e8f3..864fea20c 100644
--- a/tests/roots/test-ext-autodoc/target/typevar.py
+++ b/tests/roots/test-ext-autodoc/target/typevar.py
@@ -19,7 +19,8 @@ T6 = NewType("T6", int)
class Class:
- # TODO: TypeVar
+ #: T1
+ T1 = TypeVar("T1")
#: T6
T6 = NewType("T6", int)
diff --git a/tests/test_ext_autodoc.py b/tests/test_ext_autodoc.py
index 9b80d8669..4b18da862 100644
--- a/tests/test_ext_autodoc.py
+++ b/tests/test_ext_autodoc.py
@@ -1735,6 +1735,14 @@ def test_autodoc_TypeVar(app):
' :module: target.typevar',
'',
'',
+ ' .. py:attribute:: Class.T1',
+ ' :module: target.typevar',
+ '',
+ ' T1',
+ '',
+ " alias of TypeVar('T1')",
+ '',
+ '',
' .. py:attribute:: Class.T6',
' :module: target.typevar',
'',
@@ -1750,6 +1758,7 @@ def test_autodoc_TypeVar(app):
'',
" alias of TypeVar('T1')",
'',
+ '',
'.. py:data:: T3',
' :module: target.typevar',
'',
@@ -1757,6 +1766,7 @@ def test_autodoc_TypeVar(app):
'',
" alias of TypeVar('T3', int, str)",
'',
+ '',
'.. py:data:: T4',
' :module: target.typevar',
'',
@@ -1764,6 +1774,7 @@ def test_autodoc_TypeVar(app):
'',
" alias of TypeVar('T4', covariant=True)",
'',
+ '',
'.. py:data:: T5',
' :module: target.typevar',
'',
@@ -1771,6 +1782,7 @@ def test_autodoc_TypeVar(app):
'',
" alias of TypeVar('T5', contravariant=True)",
'',
+ '',
'.. py:data:: T6',
' :module: target.typevar',
'',
diff --git a/tests/test_ext_autodoc_autoattribute.py b/tests/test_ext_autodoc_autoattribute.py
index 28c48d081..4787530de 100644
--- a/tests/test_ext_autodoc_autoattribute.py
+++ b/tests/test_ext_autodoc_autoattribute.py
@@ -85,3 +85,18 @@ def test_autoattribute_NewType(app):
' alias of :class:`int`',
'',
]
+
+
+@pytest.mark.sphinx('html', testroot='ext-autodoc')
+def test_autoattribute_TypeVar(app):
+ actual = do_autodoc(app, 'attribute', 'target.typevar.Class.T1')
+ assert list(actual) == [
+ '',
+ '.. py:attribute:: Class.T1',
+ ' :module: target.typevar',
+ '',
+ ' T1',
+ '',
+ " alias of TypeVar('T1')",
+ '',
+ ]
diff --git a/tests/test_ext_autodoc_autodata.py b/tests/test_ext_autodoc_autodata.py
index 9c765676f..dbf6103cb 100644
--- a/tests/test_ext_autodoc_autodata.py
+++ b/tests/test_ext_autodoc_autodata.py
@@ -88,3 +88,18 @@ def test_autodata_NewType(app):
' alias of :class:`int`',
'',
]
+
+
+@pytest.mark.sphinx('html', testroot='ext-autodoc')
+def test_autodata_TypeVar(app):
+ actual = do_autodoc(app, 'data', 'target.typevar.T1')
+ assert list(actual) == [
+ '',
+ '.. py:data:: T1',
+ ' :module: target.typevar',
+ '',
+ ' T1',
+ '',
+ " alias of TypeVar('T1')",
+ '',
+ ]