summaryrefslogtreecommitdiffstats
path: root/Doc/tools
diff options
context:
space:
mode:
authorJulien Palard <julien@palard.fr>2020-07-06 20:28:15 (GMT)
committerGitHub <noreply@github.com>2020-07-06 20:28:15 (GMT)
commita103e73ce8d34e3af5f556ee9090ce89249d565e (patch)
treec245c98acb593c10e2991ad30049876111fa12df /Doc/tools
parent1ac0cbca369f16f9191833dd54536482fb141a98 (diff)
downloadcpython-a103e73ce8d34e3af5f556ee9090ce89249d565e.zip
cpython-a103e73ce8d34e3af5f556ee9090ce89249d565e.tar.gz
cpython-a103e73ce8d34e3af5f556ee9090ce89249d565e.tar.bz2
bpo-40742: Doc: fix parallel build. (GH-21237)
Diffstat (limited to 'Doc/tools')
-rw-r--r--Doc/tools/extensions/pyspecific.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py
index 46064fa..008dd8a 100644
--- a/Doc/tools/extensions/pyspecific.py
+++ b/Doc/tools/extensions/pyspecific.py
@@ -125,6 +125,39 @@ class Availability(Directive):
# Support for documenting audit event
+def audit_events_purge(app, env, docname):
+ """This is to remove from env.all_audit_events old traces of removed
+ documents.
+ """
+ if not hasattr(env, 'all_audit_events'):
+ return
+ fresh_all_audit_events = {}
+ for name, event in env.all_audit_events.items():
+ event["source"] = [(d, t) for d, t in event["source"] if d != docname]
+ if event["source"]:
+ # Only keep audit_events that have at least one source.
+ fresh_all_audit_events[name] = event
+ env.all_audit_events = fresh_all_audit_events
+
+
+def audit_events_merge(app, env, docnames, other):
+ """In Sphinx parallel builds, this merges env.all_audit_events from
+ subprocesses.
+
+ all_audit_events is a dict of names, with values like:
+ {'source': [(docname, target), ...], 'args': args}
+ """
+ if not hasattr(other, 'all_audit_events'):
+ return
+ if not hasattr(env, 'all_audit_events'):
+ env.all_audit_events = {}
+ for name, value in other.all_audit_events.items():
+ if name in env.all_audit_events:
+ env.all_audit_events[name]["source"].extend(value["source"])
+ else:
+ env.all_audit_events[name] = value
+
+
class AuditEvent(Directive):
has_content = True
@@ -589,4 +622,6 @@ def setup(app):
app.add_directive_to_domain('py', 'abstractmethod', PyAbstractMethod)
app.add_directive('miscnews', MiscNews)
app.connect('doctree-resolved', process_audit_events)
+ app.connect('env-merge-info', audit_events_merge)
+ app.connect('env-purge-doc', audit_events_purge)
return {'version': '1.0', 'parallel_read_safe': True}