diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2021-09-01 00:16:24 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-01 00:16:24 +0900 |
commit | 80fbbb8462f075644e229c9d00293d4afde7adf2 (patch) | |
tree | 0f18fceeb3558975750aa15618a2b86508b19f2f | |
parent | 9ed054279aeffd5b1d0642e2d24a8800389de29f (diff) | |
parent | 3e24190564451967cd070a6d0c4e0e8612edc3eb (diff) | |
download | sphinx-git-80fbbb8462f075644e229c9d00293d4afde7adf2.tar.gz |
Merge pull request #9591 from tk0miya/9585_type_for_pyproperty
Fix #9585: py:property directive does not create a hyperlink for types
-rw-r--r-- | CHANGES | 2 | ||||
-rw-r--r-- | sphinx/domains/python.py | 3 | ||||
-rw-r--r-- | tests/test_domain_py.py | 6 |
3 files changed, 8 insertions, 3 deletions
@@ -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 diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py index e8330e81c..9875a9f4b 100644 --- a/sphinx/domains/python.py +++ b/sphinx/domains/python.py @@ -861,7 +861,8 @@ class PyProperty(PyObject): 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 diff --git a/tests/test_domain_py.py b/tests/test_domain_py.py index 8b72f8b7a..067febcf4 100644 --- a/tests/test_domain_py.py +++ b/tests/test_domain_py.py @@ -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) |