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 <foobar>`
    .. baz:: foo bar
This commit is contained in:
Guillaume Melquiond 2020-02-18 08:07:11 +01:00
parent ee0656f51f
commit cea18198ce

View File

@ -62,7 +62,7 @@ class GenericObject(ObjectDescription):
signode.clear() signode.clear()
signode += addnodes.desc_name(sig, sig) signode += addnodes.desc_name(sig, sig)
# normalize whitespace like XRefRole does # normalize whitespace like XRefRole does
name = ws_re.sub('', sig) name = ws_re.sub(' ', sig)
return name return name
def add_target_and_index(self, name: str, sig: str, signode: desc_signature) -> None: def add_target_and_index(self, name: str, sig: str, signode: desc_signature) -> None: