mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #10021 from tk0miya/10015_typehints_format_with_typehints_in_description
Fix #10015: autodoc: autodoc_typehints_format='short' does not work when autodoc_typehints='description'
This commit is contained in:
@@ -1196,7 +1196,9 @@ def test_type_field(app):
|
||||
text = (".. py:data:: var1\n"
|
||||
" :type: .int\n"
|
||||
".. py:data:: var2\n"
|
||||
" :type: ~builtins.int\n")
|
||||
" :type: ~builtins.int\n"
|
||||
".. py:data:: var3\n"
|
||||
" :type: typing.Optional[typing.Tuple[int, typing.Any]]\n")
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
assert_node(doctree, (addnodes.index,
|
||||
[desc, ([desc_signature, ([desc_name, "var1"],
|
||||
@@ -1209,9 +1211,28 @@ def test_type_field(app):
|
||||
[desc_annotation, ([desc_sig_punctuation, ':'],
|
||||
desc_sig_space,
|
||||
[pending_xref, "int"])])],
|
||||
[desc_content, ()])],
|
||||
addnodes.index,
|
||||
[desc, ([desc_signature, ([desc_name, "var3"],
|
||||
[desc_annotation, ([desc_sig_punctuation, ":"],
|
||||
desc_sig_space,
|
||||
[pending_xref, "Optional"],
|
||||
[desc_sig_punctuation, "["],
|
||||
[pending_xref, "Tuple"],
|
||||
[desc_sig_punctuation, "["],
|
||||
[pending_xref, "int"],
|
||||
[desc_sig_punctuation, ","],
|
||||
desc_sig_space,
|
||||
[pending_xref, "Any"],
|
||||
[desc_sig_punctuation, "]"],
|
||||
[desc_sig_punctuation, "]"])])],
|
||||
[desc_content, ()])]))
|
||||
assert_node(doctree[1][0][1][2], pending_xref, reftarget='int', refspecific=True)
|
||||
assert_node(doctree[3][0][1][2], pending_xref, reftarget='builtins.int', refspecific=False)
|
||||
assert_node(doctree[5][0][1][2], pending_xref, reftarget='typing.Optional', refspecific=False)
|
||||
assert_node(doctree[5][0][1][4], pending_xref, reftarget='typing.Tuple', refspecific=False)
|
||||
assert_node(doctree[5][0][1][6], pending_xref, reftarget='int', refspecific=False)
|
||||
assert_node(doctree[5][0][1][9], pending_xref, reftarget='typing.Any', refspecific=False)
|
||||
|
||||
|
||||
@pytest.mark.sphinx(freshenv=True)
|
||||
|
||||
@@ -835,7 +835,7 @@ def test_autodoc_typehints_description(app):
|
||||
' **x** (*Tuple**[**int**, **Union**[**int**, **str**]**]*) --\n'
|
||||
'\n'
|
||||
' Return type:\n'
|
||||
' Tuple[int, int]\n'
|
||||
' *Tuple*[int, int]\n'
|
||||
in context)
|
||||
|
||||
# Overloads still get displayed in the signature
|
||||
@@ -887,7 +887,7 @@ def test_autodoc_typehints_description_no_undoc(app):
|
||||
' another tuple\n'
|
||||
'\n'
|
||||
' Return type:\n'
|
||||
' Tuple[int, int]\n'
|
||||
' *Tuple*[int, int]\n'
|
||||
in context)
|
||||
|
||||
|
||||
@@ -978,7 +978,7 @@ def test_autodoc_typehints_both(app):
|
||||
' **x** (*Tuple**[**int**, **Union**[**int**, **str**]**]*) --\n'
|
||||
'\n'
|
||||
' Return type:\n'
|
||||
' Tuple[int, int]\n'
|
||||
' *Tuple*[int, int]\n'
|
||||
in context)
|
||||
|
||||
# Overloads still get displayed in the signature
|
||||
|
||||
Reference in New Issue
Block a user