summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Lykke Andersen <Jakob@caput.dk>2021-09-25 13:03:24 +0200
committerJakob Lykke Andersen <Jakob@caput.dk>2021-10-02 12:41:40 +0200
commitae7865aaf8b23585526176e8e48f7f5d1952d69f (patch)
treee333f56e2a1f988a35190928b48ec90e2ecde108
parent5a3b7f130d65d291c849806588a6da31f1f83e17 (diff)
downloadsphinx-git-ae7865aaf8b23585526176e8e48f7f5d1952d69f.tar.gz
py nodes, PyProperty get_signature_prefix
-rw-r--r--sphinx/domains/python.py15
-rw-r--r--tests/test_domain_py.py6
2 files changed, 13 insertions, 8 deletions
diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py
index 4238ab45d..48370d6c7 100644
--- a/sphinx/domains/python.py
+++ b/sphinx/domains/python.py
@@ -903,15 +903,18 @@ class PyProperty(PyObject):
return fullname, prefix
- def get_signature_prefix(self, sig: str) -> str:
- prefix = []
+ def get_signature_prefix(self, sig: str) -> List[nodes.Node]:
+ prefix: List[nodes.Node] = []
if 'abstractmethod' in self.options:
- prefix.append('abstract')
+ prefix.append(nodes.Text('abstract'))
+ prefix.append(addnodes.desc_sig_space())
if 'classmethod' in self.options:
- prefix.append('class')
+ prefix.append(nodes.Text('class'))
+ prefix.append(addnodes.desc_sig_space())
- prefix.append('property')
- return ' '.join(prefix) + ' '
+ prefix.append(nodes.Text('property'))
+ prefix.append(addnodes.desc_sig_space())
+ return prefix
def get_index_text(self, modname: str, name_cls: Tuple[str, str]) -> str:
name, cls = name_cls
diff --git a/tests/test_domain_py.py b/tests/test_domain_py.py
index 4b29e7568..59d8b4ca1 100644
--- a/tests/test_domain_py.py
+++ b/tests/test_domain_py.py
@@ -879,7 +879,8 @@ def test_pyproperty(app):
desc)])]))
assert_node(doctree[1][1][0], addnodes.index,
entries=[('single', 'prop1 (Class property)', 'Class.prop1', '', None)])
- assert_node(doctree[1][1][1], ([desc_signature, ([desc_annotation, "abstract property "],
+ assert_node(doctree[1][1][1], ([desc_signature, ([desc_annotation, ("abstract", desc_sig_space,
+ "property", desc_sig_space)],
[desc_name, "prop1"],
[desc_annotation, ([desc_sig_punctuation, ':'],
desc_sig_space,
@@ -887,7 +888,8 @@ def test_pyproperty(app):
[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 "],
+ assert_node(doctree[1][1][3], ([desc_signature, ([desc_annotation, ("class", desc_sig_space,
+ "property", desc_sig_space)],
[desc_name, "prop2"],
[desc_annotation, ([desc_sig_punctuation, ':'],
desc_sig_space,