summaryrefslogtreecommitdiff
path: root/tests/test_domain_py.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-04-17 02:06:57 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2021-04-17 02:06:57 +0900
commitc7b169c5a95f9d84583afcfe18773742a67cdef0 (patch)
tree2459d241696890a96df328de1c6e972ff8a1b137 /tests/test_domain_py.py
parent8954770f677994cfb13d93ea6d08b13db5382e31 (diff)
downloadsphinx-git-c7b169c5a95f9d84583afcfe18773742a67cdef0.tar.gz
Fix #8127: py domain: Ellipsis in info-field-list causes nit-picky warning
On parsing the types, the leading dot of the ellipsis (...) is considered as a reference name. And its first dot is considered as a notation for relative type reference (ex. ".ClassName"). As a result, it was converted double dots unexpectedly. This changes the parsing rule to treat the ellipsis as a symbol, not a name.
Diffstat (limited to 'tests/test_domain_py.py')
-rw-r--r--tests/test_domain_py.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/test_domain_py.py b/tests/test_domain_py.py
index f5df9084b..214cb58a0 100644
--- a/tests/test_domain_py.py
+++ b/tests/test_domain_py.py
@@ -876,7 +876,9 @@ def test_info_field_list(app):
"\n"
" :param str name: blah blah\n"
" :param age: blah blah\n"
- " :type age: int\n")
+ " :type age: int\n"
+ " :param items: blah blah\n"
+ " :type items: Tuple[str, ...]\n")
doctree = restructuredtext.parse(app, text)
print(doctree)
@@ -890,6 +892,7 @@ def test_info_field_list(app):
assert_node(doctree[3][1][0][0],
([nodes.field_name, "Parameters"],
[nodes.field_body, nodes.bullet_list, ([nodes.list_item, nodes.paragraph],
+ [nodes.list_item, nodes.paragraph],
[nodes.list_item, nodes.paragraph])]))
# :param str name:
@@ -916,6 +919,26 @@ def test_info_field_list(app):
refdomain="py", reftype="class", reftarget="int",
**{"py:module": "example", "py:class": "Class"})
+ # :param items: + :type items:
+ assert_node(doctree[3][1][0][0][1][0][2][0],
+ ([addnodes.literal_strong, "items"],
+ " (",
+ [pending_xref, addnodes.literal_emphasis, "Tuple"],
+ [addnodes.literal_emphasis, "["],
+ [pending_xref, addnodes.literal_emphasis, "str"],
+ [addnodes.literal_emphasis, ", "],
+ [addnodes.literal_emphasis, "..."],
+ [addnodes.literal_emphasis, "]"],
+ ")",
+ " -- ",
+ "blah blah"))
+ assert_node(doctree[3][1][0][0][1][0][2][0][2], pending_xref,
+ refdomain="py", reftype="class", reftarget="Tuple",
+ **{"py:module": "example", "py:class": "Class"})
+ assert_node(doctree[3][1][0][0][1][0][2][0][4], pending_xref,
+ refdomain="py", reftype="class", reftarget="str",
+ **{"py:module": "example", "py:class": "Class"})
+
def test_info_field_list_var(app):
text = (".. py:class:: Class\n"