summaryrefslogtreecommitdiffstats
path: root/Doc/tools
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-07-01 23:22:29 (GMT)
committerGitHub <noreply@github.com>2019-07-01 23:22:29 (GMT)
commit746992c1ae4c632220563d3fe54123498f93db1d (patch)
tree76343ab9ba2a15f8e840b9d98282a67575433a2f /Doc/tools
parent91f9f098fcdb023dbb89d06c8833e89a11cbae4c (diff)
downloadcpython-746992c1ae4c632220563d3fe54123498f93db1d.zip
cpython-746992c1ae4c632220563d3fe54123498f93db1d.tar.gz
cpython-746992c1ae4c632220563d3fe54123498f93db1d.tar.bz2
bpo-37363: Add audit events on startup for the run commands (GH-14524)
(cherry picked from commit e226e83d36dfc7220d836fb7a249ce18e70cb4a6) Co-authored-by: Steve Dower <steve.dower@python.org>
Diffstat (limited to 'Doc/tools')
-rw-r--r--Doc/tools/extensions/pyspecific.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py
index 9b38f8a..28b8bda 100644
--- a/Doc/tools/extensions/pyspecific.py
+++ b/Doc/tools/extensions/pyspecific.py
@@ -199,13 +199,18 @@ class AuditEvent(Directive):
.format(name, info['args'], new_info['args'])
)
- if len(self.arguments) >= 3 and self.arguments[2]:
- target = self.arguments[2]
- ids = []
- else:
- target = "audit_event_{}_{}".format(name, len(info['source']))
- target = re.sub(r'\W', '_', label)
- ids = [target]
+ ids = []
+ try:
+ target = self.arguments[2].strip("\"'")
+ except (IndexError, TypeError):
+ target = None
+ if not target:
+ target = "audit_event_{}_{}".format(
+ re.sub(r'\W', '_', name),
+ len(info['source']),
+ )
+ ids.append(target)
+
info['source'].append((env.docname, target))
pnode = nodes.paragraph(text, classes=["audit-hook"], ids=ids)
@@ -560,7 +565,8 @@ def process_audit_events(app, doctree, fromdocname):
row += nodes.entry('', node)
node = nodes.paragraph()
- for i, (doc, label) in enumerate(audit_event['source'], start=1):
+ backlinks = enumerate(sorted(set(audit_event['source'])), start=1)
+ for i, (doc, label) in backlinks:
if isinstance(label, str):
ref = nodes.reference("", nodes.Text("[{}]".format(i)), internal=True)
ref['refuri'] = "{}#{}".format(