Skip to content

Commit 80fbbb8

Browse files
authored
Merge pull request #9591 from tk0miya/9585_type_for_pyproperty
Fix #9585: py:property directive does not create a hyperlink for types
2 parents 9ed0542 + 3e24190 commit 80fbbb8

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ Bugs fixed
3838
* #9456: html search: abbreation marks are inserted to the search result if
3939
failed to fetch the content of the page
4040
* #9267: html theme: CSS and JS files added by theme were loaded twice
41+
* #9585: py domain: ``:type:`` option for :rst:dir:`py:property` directive does
42+
not create a hyperlink
4143
* #9535 comment: C++, fix parsing of defaulted function parameters that are
4244
function pointers.
4345
* #9564: smartquotes: don't adjust typography for text with

sphinx/domains/python.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,8 @@ def handle_signature(self, sig: str, signode: desc_signature) -> Tuple[str, str]
861861

862862
typ = self.options.get('type')
863863
if typ:
864-
signode += addnodes.desc_annotation(typ, ': ' + typ)
864+
annotations = _parse_annotation(typ, self.env)
865+
signode += addnodes.desc_annotation(typ, '', nodes.Text(': '), *annotations)
865866

866867
return fullname, prefix
867868

tests/test_domain_py.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,13 +833,15 @@ def test_pyproperty(app):
833833
entries=[('single', 'prop1 (Class property)', 'Class.prop1', '', None)])
834834
assert_node(doctree[1][1][1], ([desc_signature, ([desc_annotation, "abstract property "],
835835
[desc_name, "prop1"],
836-
[desc_annotation, ": str"])],
836+
[desc_annotation, (": ",
837+
[pending_xref, "str"])])],
837838
[desc_content, ()]))
838839
assert_node(doctree[1][1][2], addnodes.index,
839840
entries=[('single', 'prop2 (Class property)', 'Class.prop2', '', None)])
840841
assert_node(doctree[1][1][3], ([desc_signature, ([desc_annotation, "class property "],
841842
[desc_name, "prop2"],
842-
[desc_annotation, ": str"])],
843+
[desc_annotation, (": ",
844+
[pending_xref, "str"])])],
843845
[desc_content, ()]))
844846
assert 'Class.prop1' in domain.objects
845847
assert domain.objects['Class.prop1'] == ('index', 'Class.prop1', 'property', False)

0 commit comments

Comments
 (0)