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"})