Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions sphinx/transforms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,20 @@ def apply(self, **kwargs: Any) -> None:
domain: StandardDomain = self.env.domains.standard_domain

for node in self.document.findall(nodes.Element):
if (
domain.is_enumerable_node(node)
and domain.get_numfig_title(node) is not None
and node['ids'] == []
):
if not domain.is_enumerable_node(node):
continue
refname = domain.get_numfig_title(node)
if refname and node['ids'] == []:
if not node['names'] and not getattr(
self.document.settings, 'legacy_ids', True
):
# cf. https://docutils.sf.net/docs/user/config.html#legacy-ids
node['names'].append(nodes.fully_normalize_name(refname))
self.document.note_implicit_target(node)
# Since Docutils 0.23, `note_implicit_targets()` does not
# set an ID if "legacy_ids" is False:
if not getattr(self.document.settings, 'legacy_ids', True):
self.document.set_id(node)


class SortIds(SphinxTransform):
Expand Down
Loading