summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-01-01 23:00:44 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-01-13 13:23:45 +0900
commitffdfb6cb877421009bcdf70715cf15ffeefbb015 (patch)
treeac50580c62e051b4059995c447a255a297bda2f9 /tests
parent74a5f350a19e9a54ef53c653c95d7741f3de4e0e (diff)
downloadsphinx-git-ffdfb6cb877421009bcdf70715cf15ffeefbb015.tar.gz
Close #2755: autodoc: Support type_comment style annotation
Note: python3.8+ or typed_ast is required
Diffstat (limited to 'tests')
-rw-r--r--tests/roots/test-ext-autodoc/target/typehints.py14
-rw-r--r--tests/test_ext_autodoc_configs.py25
2 files changed, 39 insertions, 0 deletions
diff --git a/tests/roots/test-ext-autodoc/target/typehints.py b/tests/roots/test-ext-autodoc/target/typehints.py
index eedaab3b9..842530c13 100644
--- a/tests/roots/test-ext-autodoc/target/typehints.py
+++ b/tests/roots/test-ext-autodoc/target/typehints.py
@@ -2,9 +2,23 @@ def incr(a: int, b: int = 1) -> int:
return a + b
+def decr(a, b = 1):
+ # type: (int, int) -> int
+ return a - b
+
+
class Math:
def __init__(self, s: str, o: object = None) -> None:
pass
def incr(self, a: int, b: int = 1) -> int:
return a + b
+
+ def decr(self, a, b = 1):
+ # type: (int, int) -> int
+ return a - b
+
+
+def complex_func(arg1, arg2, arg3=None, *args, **kwargs):
+ # type: (str, List[int], Tuple[int, Union[str, Unknown]], *str, **str) -> None
+ pass
diff --git a/tests/test_ext_autodoc_configs.py b/tests/test_ext_autodoc_configs.py
index 81fd5a49c..0da91c7f0 100644
--- a/tests/test_ext_autodoc_configs.py
+++ b/tests/test_ext_autodoc_configs.py
@@ -479,10 +479,23 @@ def test_autodoc_typehints_signature(app):
' :module: target.typehints',
'',
' ',
+ ' .. py:method:: Math.decr(a: int, b: int = 1) -> int',
+ ' :module: target.typehints',
+ ' ',
+ ' ',
' .. py:method:: Math.incr(a: int, b: int = 1) -> int',
' :module: target.typehints',
' ',
'',
+ '.. py:function:: complex_func(arg1: str, arg2: List[int], arg3: Tuple[int, '
+ 'Union[str, Unknown]] = None, *args: str, **kwargs: str) -> None',
+ ' :module: target.typehints',
+ '',
+ '',
+ '.. py:function:: decr(a: int, b: int = 1) -> int',
+ ' :module: target.typehints',
+ '',
+ '',
'.. py:function:: incr(a: int, b: int = 1) -> int',
' :module: target.typehints',
''
@@ -505,10 +518,22 @@ def test_autodoc_typehints_none(app):
' :module: target.typehints',
'',
' ',
+ ' .. py:method:: Math.decr(a, b=1)',
+ ' :module: target.typehints',
+ ' ',
+ ' ',
' .. py:method:: Math.incr(a, b=1)',
' :module: target.typehints',
' ',
'',
+ '.. py:function:: complex_func(arg1, arg2, arg3=None, *args, **kwargs)',
+ ' :module: target.typehints',
+ '',
+ '',
+ '.. py:function:: decr(a, b=1)',
+ ' :module: target.typehints',
+ '',
+ '',
'.. py:function:: incr(a, b=1)',
' :module: target.typehints',
''