From cea18198ce6a474e1ce0deaf78e79895748bd119 Mon Sep 17 00:00:00 2001 From: Guillaume Melquiond Date: Tue, 18 Feb 2020 08:07:11 +0100 Subject: [PATCH] Fix broken handling of whitespace in GenericObject. This actually makes the code matches its comment, i.e, whitespaces are now normalized the same way XRefRole does. Without the fix, when creating a directive/role via add_object_type, the following testcase fails with "WARNING: 'baz' reference target not found: foo bar". :baz:`foo bar` .. baz:: foo bar The current workaround is to explicitly mention the broken target, e.g., :baz:`foo bar ` .. baz:: foo bar --- sphinx/domains/std.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/domains/std.py b/sphinx/domains/std.py index 52633d194..ae868a2ee 100644 --- a/sphinx/domains/std.py +++ b/sphinx/domains/std.py @@ -62,7 +62,7 @@ class GenericObject(ObjectDescription): signode.clear() signode += addnodes.desc_name(sig, sig) # normalize whitespace like XRefRole does - name = ws_re.sub('', sig) + name = ws_re.sub(' ', sig) return name def add_target_and_index(self, name: str, sig: str, signode: desc_signature) -> None: