diff options
author | Jakob Lykke Andersen <Jakob@caput.dk> | 2021-09-25 12:17:24 +0200 |
---|---|---|
committer | Jakob Lykke Andersen <Jakob@caput.dk> | 2021-10-02 12:41:40 +0200 |
commit | 3a1bd32665b7dc9b459913ecc4e8122a8bc2660f (patch) | |
tree | 2e061f36d98cb23a8c82e90d74feae2a62fcb2f3 | |
parent | 92a9df74514b6b544208586610e8ebbf3fb0468f (diff) | |
download | sphinx-git-3a1bd32665b7dc9b459913ecc4e8122a8bc2660f.tar.gz |
py nodes, arglist
-rw-r--r-- | sphinx/domains/python.py | 6 | ||||
-rw-r--r-- | tests/test_domain_py.py | 26 |
2 files changed, 16 insertions, 16 deletions
diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py index 3e7b5c9ad..4faf3bd38 100644 --- a/sphinx/domains/python.py +++ b/sphinx/domains/python.py @@ -228,13 +228,13 @@ def _parse_arglist(arglist: str, env: BuildEnvironment = None) -> addnodes.desc_ if param.annotation is not param.empty: children = _parse_annotation(param.annotation, env) node += addnodes.desc_sig_punctuation('', ':') - node += nodes.Text(' ') + node += addnodes.desc_sig_space() node += addnodes.desc_sig_name('', '', *children) # type: ignore if param.default is not param.empty: if param.annotation is not param.empty: - node += nodes.Text(' ') + node += addnodes.desc_sig_space() node += addnodes.desc_sig_operator('', '=') - node += nodes.Text(' ') + node += addnodes.desc_sig_space() else: node += addnodes.desc_sig_operator('', '=') node += nodes.inline('', param.default, classes=['default_value'], diff --git a/tests/test_domain_py.py b/tests/test_domain_py.py index d216259a2..840ba6828 100644 --- a/tests/test_domain_py.py +++ b/tests/test_domain_py.py @@ -291,7 +291,7 @@ def test_parse_annotation(app): [desc_sig_punctuation, "["], [pending_xref, "int"], [desc_sig_punctuation, ","], - [desc_sig_space], + desc_sig_space, [pending_xref, "int"], [desc_sig_punctuation, "]"])) @@ -307,7 +307,7 @@ def test_parse_annotation(app): [desc_sig_punctuation, "["], [pending_xref, "int"], [desc_sig_punctuation, ","], - [desc_sig_space], + desc_sig_space, [desc_sig_punctuation, "..."], [desc_sig_punctuation, "]"])) @@ -385,7 +385,7 @@ def test_pyfunction_signature(app): assert_node(doctree[1][0][1], [desc_parameterlist, desc_parameter, ([desc_sig_name, "name"], [desc_sig_punctuation, ":"], - " ", + desc_sig_space, [nodes.inline, pending_xref, "str"])]) @@ -403,7 +403,7 @@ def test_pyfunction_signature_full(app): assert_node(doctree[1][0][1], [desc_parameterlist, ([desc_parameter, ([desc_sig_name, "a"], [desc_sig_punctuation, ":"], - " ", + desc_sig_space, [desc_sig_name, pending_xref, "str"])], [desc_parameter, ([desc_sig_name, "b"], [desc_sig_operator, "="], @@ -411,28 +411,28 @@ def test_pyfunction_signature_full(app): [desc_parameter, ([desc_sig_operator, "*"], [desc_sig_name, "args"], [desc_sig_punctuation, ":"], - " ", + desc_sig_space, [desc_sig_name, pending_xref, "str"])], [desc_parameter, ([desc_sig_name, "c"], [desc_sig_punctuation, ":"], - " ", + desc_sig_space, [desc_sig_name, pending_xref, "bool"], - " ", + desc_sig_space, [desc_sig_operator, "="], - " ", + desc_sig_space, [nodes.inline, "True"])], [desc_parameter, ([desc_sig_name, "d"], [desc_sig_punctuation, ":"], - " ", + desc_sig_space, [desc_sig_name, pending_xref, "tuple"], - " ", + desc_sig_space, [desc_sig_operator, "="], - " ", + desc_sig_space, [nodes.inline, "(1, 2)"])], [desc_parameter, ([desc_sig_operator, "**"], [desc_sig_name, "kwargs"], [desc_sig_punctuation, ":"], - " ", + desc_sig_space, [desc_sig_name, pending_xref, "str"])])]) @@ -491,7 +491,7 @@ def test_pyfunction_with_union_type_operator(app): assert_node(doctree[1][0][1], [desc_parameterlist, ([desc_parameter, ([desc_sig_name, "age"], [desc_sig_punctuation, ":"], - " ", + desc_sig_space, [desc_sig_name, ([pending_xref, "int"], desc_sig_space, [desc_sig_punctuation, "|"], |