Skip to content

Commit

Permalink
Merge pull request #9591 from tk0miya/9585_type_for_pyproperty
Browse files Browse the repository at this point in the history
Fix #9585: py:property directive does not create a hyperlink for types
  • Loading branch information
tk0miya committed Aug 31, 2021
2 parents 9ed0542 + 3e24190 commit 80fbbb8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -38,6 +38,8 @@ Bugs fixed
* #9456: html search: abbreation marks are inserted to the search result if
failed to fetch the content of the page
* #9267: html theme: CSS and JS files added by theme were loaded twice
* #9585: py domain: ``:type:`` option for :rst:dir:`py:property` directive does
not create a hyperlink
* #9535 comment: C++, fix parsing of defaulted function parameters that are
function pointers.
* #9564: smartquotes: don't adjust typography for text with
Expand Down
3 changes: 2 additions & 1 deletion sphinx/domains/python.py
Expand Up @@ -861,7 +861,8 @@ def handle_signature(self, sig: str, signode: desc_signature) -> Tuple[str, str]

typ = self.options.get('type')
if typ:
signode += addnodes.desc_annotation(typ, ': ' + typ)
annotations = _parse_annotation(typ, self.env)
signode += addnodes.desc_annotation(typ, '', nodes.Text(': '), *annotations)

return fullname, prefix

Expand Down
6 changes: 4 additions & 2 deletions tests/test_domain_py.py
Expand Up @@ -833,13 +833,15 @@ def test_pyproperty(app):
entries=[('single', 'prop1 (Class property)', 'Class.prop1', '', None)])
assert_node(doctree[1][1][1], ([desc_signature, ([desc_annotation, "abstract property "],
[desc_name, "prop1"],
[desc_annotation, ": str"])],
[desc_annotation, (": ",
[pending_xref, "str"])])],
[desc_content, ()]))
assert_node(doctree[1][1][2], addnodes.index,
entries=[('single', 'prop2 (Class property)', 'Class.prop2', '', None)])
assert_node(doctree[1][1][3], ([desc_signature, ([desc_annotation, "class property "],
[desc_name, "prop2"],
[desc_annotation, ": str"])],
[desc_annotation, (": ",
[pending_xref, "str"])])],
[desc_content, ()]))
assert 'Class.prop1' in domain.objects
assert domain.objects['Class.prop1'] == ('index', 'Class.prop1', 'property', False)
Expand Down

0 comments on commit 80fbbb8

Please sign in to comment.