Skip to content

Commit 9dbf63b

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 matter 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 999855b commit 9dbf63b

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎Doc/tools/extensions/audit_events.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ 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 id_for(self, name, docname) -> str:
72+
sources = self.sources.get(name, set())
73+
source_count = sum(1 for doc, _ in sources if doc == docname)
7374
name_clean = re.sub(r"\W", "_", name)
7475
return f"audit_event_{name_clean}_{source_count}"
7576

@@ -142,7 +143,7 @@ def run(self) -> list[nodes.paragraph]:
142143
except (IndexError, TypeError):
143144
target = None
144145
if not target:
145-
target = self.env.audit_events.id_for(name)
146+
target = self.env.audit_events.id_for(name, self.env.docname)
146147
ids.append(target)
147148
self.env.audit_events.add_event(name, args, (self.env.docname, target))
148149

0 commit comments

Comments
 (0)