From 73ade60654793bc3d7db4bca4455f81275dc973a Mon Sep 17 00:00:00 2001 From: Jakob Lykke Andersen Date: Sat, 25 Sep 2021 12:34:42 +0200 Subject: [PATCH] py nodes, PyAttribute value --- sphinx/domains/python.py | 6 +++++- tests/test_domain_py.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py index 5c8780bfc..5c6db3696 100644 --- a/sphinx/domains/python.py +++ b/sphinx/domains/python.py @@ -850,7 +850,11 @@ class PyAttribute(PyObject): value = self.options.get('value') if value: - signode += addnodes.desc_annotation(value, ' = ' + value) + signode += addnodes.desc_annotation(value, '', + addnodes.desc_sig_space(), + addnodes.desc_sig_punctuation('', '='), + addnodes.desc_sig_space(), + nodes.Text(value)) return fullname, prefix diff --git a/tests/test_domain_py.py b/tests/test_domain_py.py index f22f75c6c..6e799ae79 100644 --- a/tests/test_domain_py.py +++ b/tests/test_domain_py.py @@ -841,7 +841,11 @@ def test_pyattribute(app): [desc_sig_punctuation, "["], [pending_xref, "str"], [desc_sig_punctuation, "]"])], - [desc_annotation, " = ''"])], + [desc_annotation, (desc_sig_space, + [desc_sig_punctuation, '='], + desc_sig_space, + "''")] + )], [desc_content, ()])) assert_node(doctree[1][1][1][0][1][2], pending_xref, **{"py:class": "Class"}) assert_node(doctree[1][1][1][0][1][4], pending_xref, **{"py:class": "Class"})