Skip to content

Commit

Permalink
Fix sphinx-doc#9775: py domain: Literal typehint was converted to a c…
Browse files Browse the repository at this point in the history
…ross reference
  • Loading branch information
tk0miya committed Oct 30, 2021
1 parent 4c91c03 commit bf88367
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -76,6 +76,8 @@ Bugs fixed
* #9678: linkcheck: file extension was shown twice in warnings
* #9697: py domain: An index entry with parens was registered for ``py:method``
directive with ``:property:`` option
* #9775: py domain: Literal typehint was converted to a cross reference when
:confval:`autodoc_typehints='description'`
* #9708: needs_extension failed to check double-digit version correctly
* #9688: Fix :rst:dir:`code`` does not recognize ``:class:`` option

Expand Down
34 changes: 34 additions & 0 deletions tests/test_domain_py.py
Expand Up @@ -1110,6 +1110,40 @@ def test_info_field_list_piped_type(app):
**{"py:module": "example", "py:class": "Class"})


def test_info_field_list_Literal(app):
text = (".. py:module:: example\n"
".. py:class:: Class\n"
"\n"
" :param age: blah blah\n"
" :type age: Literal['foo', 'bar', 'baz']\n")
doctree = restructuredtext.parse(app, text)

assert_node(doctree,
(nodes.target,
addnodes.index,
addnodes.index,
[desc, ([desc_signature, ([desc_annotation, ("class", desc_sig_space)],
[desc_addname, "example."],
[desc_name, "Class"])],
[desc_content, nodes.field_list, nodes.field, (nodes.field_name,
nodes.field_body)])]))
assert_node(doctree[3][1][0][0][1],
([nodes.paragraph, ([addnodes.literal_strong, "age"],
" (",
[pending_xref, addnodes.literal_emphasis, "int"],
[addnodes.literal_emphasis, " | "],
[pending_xref, addnodes.literal_emphasis, "str"],
")",
" -- ",
"blah blah")],))
assert_node(doctree[3][1][0][0][1][0][2], pending_xref,
refdomain="py", reftype="class", reftarget="int",
**{"py:module": "example", "py:class": "Class"})
assert_node(doctree[3][1][0][0][1][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"
"\n"
Expand Down

0 comments on commit bf88367

Please sign in to comment.