summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Lykke Andersen <Jakob@caput.dk>2021-09-25 12:44:29 +0200
committerJakob Lykke Andersen <Jakob@caput.dk>2021-10-02 12:41:40 +0200
commit83fcc98dbcc04b09ccd55861f6f88b77acee1712 (patch)
tree5760ee75655bb4114c3470c5bc7fb314e7483048
parentedc65e676c84e5cacb3804e754998af114d9e589 (diff)
downloadsphinx-git-83fcc98dbcc04b09ccd55861f6f88b77acee1712.tar.gz
py nodes, PyFunction get_signature_prefix
-rw-r--r--sphinx/domains/python.py7
-rw-r--r--tests/test_domain_py.py4
2 files changed, 7 insertions, 4 deletions
diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py
index 63e4d8452..999a00dcf 100644
--- a/sphinx/domains/python.py
+++ b/sphinx/domains/python.py
@@ -618,11 +618,12 @@ class PyFunction(PyObject):
'async': directives.flag,
})
- def get_signature_prefix(self, sig: str) -> str:
+ def get_signature_prefix(self, sig: str) -> List[nodes.Node]:
if 'async' in self.options:
- return 'async '
+ return [addnodes.desc_sig_keyword('', 'async'),
+ addnodes.desc_sig_space()]
else:
- return ''
+ return []
def needs_arglist(self) -> bool:
return True
diff --git a/tests/test_domain_py.py b/tests/test_domain_py.py
index e2fbc5def..36b327854 100644
--- a/tests/test_domain_py.py
+++ b/tests/test_domain_py.py
@@ -18,6 +18,7 @@ from docutils import nodes
from sphinx import addnodes
from sphinx.addnodes import (desc, desc_addname, desc_annotation, desc_content, desc_name,
desc_optional, desc_parameter, desc_parameterlist, desc_returns,
+ desc_sig_keyword,
desc_sig_name, desc_sig_operator, desc_sig_punctuation,
desc_signature, desc_sig_space, pending_xref)
from sphinx.domains import IndexEntry
@@ -626,7 +627,8 @@ def test_pyfunction(app):
nodes.target,
addnodes.index,
addnodes.index,
- [desc, ([desc_signature, ([desc_annotation, "async "],
+ [desc, ([desc_signature, ([desc_annotation, ([desc_sig_keyword, 'async'],
+ desc_sig_space)],
[desc_addname, "example."],
[desc_name, "func2"],
[desc_parameterlist, ()])],