Skip to content

Commit 906a590

Browse files
committed
Doc: Generate ids for audit_events using docname
This patch generates ids for audit_events using the docname so the id is not global but depend on the source file. This make the doc build reproducible with multiple cores because it doesn't which file is parsed first, the id for audit_events will always be consistent independently of what file is parsed first. python#130979
1 parent fe119a0 commit 906a590

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Doc/tools/extensions/audit_events.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,13 @@ def _check_args_match(self, name: str, args: list[str]) -> None:
6868
logger.warning(msg)
6969
return
7070

71-
def id_for(self, name) -> str:
72-
source_count = len(self.sources.get(name, set()))
71+
def _source_count(self, name, docname) -> int:
72+
"""Count the event name in the same source"""
73+
sources = self.sources.get(name, set())
74+
return len([s for s, t in sources if s == docname])
75+
76+
def id_for(self, name, docname) -> str:
77+
source_count = self._source_count(name, docname)
7378
name_clean = re.sub(r"\W", "_", name)
7479
return f"audit_event_{name_clean}_{source_count}"
7580

@@ -142,7 +147,7 @@ def run(self) -> list[nodes.paragraph]:
142147
except (IndexError, TypeError):
143148
target = None
144149
if not target:
145-
target = self.env.audit_events.id_for(name)
150+
target = self.env.audit_events.id_for(name, self.env.docname)
146151
ids.append(target)
147152
self.env.audit_events.add_event(name, args, (self.env.docname, target))
148153

0 commit comments

Comments
 (0)