Martin v. Löwis | 5680d0c | 2008-04-10 03:06:53 +0000 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | """ |
| 3 | pyspecific.py |
| 4 | ~~~~~~~~~~~~~ |
| 5 | |
| 6 | Sphinx extension with Python doc-specific markup. |
| 7 | |
Georg Brandl | 7ed509a | 2014-01-21 19:20:31 +0100 | [diff] [blame] | 8 | :copyright: 2008-2014 by Georg Brandl. |
Martin v. Löwis | 5680d0c | 2008-04-10 03:06:53 +0000 | [diff] [blame] | 9 | :license: Python license. |
| 10 | """ |
| 11 | |
Georg Brandl | 35903c8 | 2014-10-30 22:55:13 +0100 | [diff] [blame] | 12 | import re |
Victor Stinner | 272d888 | 2017-06-16 08:59:01 +0200 | [diff] [blame] | 13 | import io |
Steve Dower | afe17a7 | 2018-12-19 18:20:06 -0800 | [diff] [blame] | 14 | from os import getenv, path |
Georg Brandl | 35903c8 | 2014-10-30 22:55:13 +0100 | [diff] [blame] | 15 | from time import asctime |
| 16 | from pprint import pformat |
| 17 | from docutils.io import StringOutput |
Ned Deily | 50f5816 | 2017-07-15 15:28:02 -0400 | [diff] [blame] | 18 | from docutils.parsers.rst import Directive |
Georg Brandl | 35903c8 | 2014-10-30 22:55:13 +0100 | [diff] [blame] | 19 | from docutils.utils import new_document |
Martin v. Löwis | 5680d0c | 2008-04-10 03:06:53 +0000 | [diff] [blame] | 20 | |
| 21 | from docutils import nodes, utils |
Georg Brandl | 239990d | 2013-10-12 20:50:21 +0200 | [diff] [blame] | 22 | |
Georg Brandl | 35903c8 | 2014-10-30 22:55:13 +0100 | [diff] [blame] | 23 | from sphinx import addnodes |
| 24 | from sphinx.builders import Builder |
Julien Palard | 63c98ed | 2019-09-09 12:54:56 +0200 | [diff] [blame] | 25 | try: |
| 26 | from sphinx.errors import NoUri |
| 27 | except ImportError: |
| 28 | from sphinx.environment import NoUri |
INADA Naoki | c351ce6 | 2017-03-08 19:07:13 +0900 | [diff] [blame] | 29 | from sphinx.locale import translators |
Steve Dower | 44f91c3 | 2019-06-27 10:47:59 -0700 | [diff] [blame] | 30 | from sphinx.util import status_iterator, logging |
Georg Brandl | 6881886 | 2010-11-06 07:19:35 +0000 | [diff] [blame] | 31 | from sphinx.util.nodes import split_explicit_title |
Benjamin Peterson | acfb087 | 2018-04-16 22:56:46 -0700 | [diff] [blame] | 32 | from sphinx.writers.text import TextWriter, TextTranslator |
Georg Brandl | 239990d | 2013-10-12 20:50:21 +0200 | [diff] [blame] | 33 | from sphinx.writers.latex import LaTeXTranslator |
Dong-hee Na | 6595cb0 | 2020-09-18 18:22:36 +0900 | [diff] [blame] | 34 | |
| 35 | try: |
| 36 | from sphinx.domains.python import PyFunction, PyMethod |
| 37 | except ImportError: |
| 38 | from sphinx.domains.python import PyClassmember as PyMethod |
| 39 | from sphinx.domains.python import PyModulelevel as PyFunction |
Georg Brandl | 35903c8 | 2014-10-30 22:55:13 +0100 | [diff] [blame] | 40 | |
| 41 | # Support for checking for suspicious markup |
| 42 | |
| 43 | import suspicious |
| 44 | |
| 45 | |
| 46 | ISSUE_URI = 'https://bugs.python.org/issue%s' |
Łukasz Langa | 9ab2fb1 | 2019-06-04 22:12:32 +0200 | [diff] [blame] | 47 | SOURCE_URI = 'https://github.com/python/cpython/tree/master/%s' |
Martin v. Löwis | 5680d0c | 2008-04-10 03:06:53 +0000 | [diff] [blame] | 48 | |
Benjamin Peterson | 5c6d787 | 2009-02-06 02:40:07 +0000 | [diff] [blame] | 49 | # monkey-patch reST parser to disable alphabetic and roman enumerated lists |
| 50 | from docutils.parsers.rst.states import Body |
| 51 | Body.enum.converters['loweralpha'] = \ |
| 52 | Body.enum.converters['upperalpha'] = \ |
| 53 | Body.enum.converters['lowerroman'] = \ |
| 54 | Body.enum.converters['upperroman'] = lambda x: None |
| 55 | |
Georg Brandl | 35903c8 | 2014-10-30 22:55:13 +0100 | [diff] [blame] | 56 | |
Georg Brandl | 495f7b5 | 2009-10-27 15:28:25 +0000 | [diff] [blame] | 57 | # Support for marking up and linking to bugs.python.org issues |
| 58 | |
Martin v. Löwis | 5680d0c | 2008-04-10 03:06:53 +0000 | [diff] [blame] | 59 | def issue_role(typ, rawtext, text, lineno, inliner, options={}, content=[]): |
| 60 | issue = utils.unescape(text) |
Brett Cannon | 79ab8be | 2017-02-10 15:10:13 -0800 | [diff] [blame] | 61 | text = 'bpo-' + issue |
Martin v. Löwis | 5680d0c | 2008-04-10 03:06:53 +0000 | [diff] [blame] | 62 | refnode = nodes.reference(text, text, refuri=ISSUE_URI % issue) |
| 63 | return [refnode], [] |
| 64 | |
| 65 | |
Georg Brandl | 6881886 | 2010-11-06 07:19:35 +0000 | [diff] [blame] | 66 | # Support for linking to Python source files easily |
| 67 | |
| 68 | def source_role(typ, rawtext, text, lineno, inliner, options={}, content=[]): |
| 69 | has_t, title, target = split_explicit_title(text) |
| 70 | title = utils.unescape(title) |
| 71 | target = utils.unescape(target) |
| 72 | refnode = nodes.reference(title, title, refuri=SOURCE_URI % target) |
| 73 | return [refnode], [] |
| 74 | |
| 75 | |
Georg Brandl | 495f7b5 | 2009-10-27 15:28:25 +0000 | [diff] [blame] | 76 | # Support for marking up implementation details |
| 77 | |
Georg Brandl | 495f7b5 | 2009-10-27 15:28:25 +0000 | [diff] [blame] | 78 | class ImplementationDetail(Directive): |
| 79 | |
| 80 | has_content = True |
| 81 | required_arguments = 0 |
| 82 | optional_arguments = 1 |
| 83 | final_argument_whitespace = True |
| 84 | |
INADA Naoki | c351ce6 | 2017-03-08 19:07:13 +0900 | [diff] [blame] | 85 | # This text is copied to templates/dummy.html |
| 86 | label_text = 'CPython implementation detail:' |
| 87 | |
Georg Brandl | 495f7b5 | 2009-10-27 15:28:25 +0000 | [diff] [blame] | 88 | def run(self): |
| 89 | pnode = nodes.compound(classes=['impl-detail']) |
INADA Naoki | c351ce6 | 2017-03-08 19:07:13 +0900 | [diff] [blame] | 90 | label = translators['sphinx'].gettext(self.label_text) |
Georg Brandl | 495f7b5 | 2009-10-27 15:28:25 +0000 | [diff] [blame] | 91 | content = self.content |
INADA Naoki | c351ce6 | 2017-03-08 19:07:13 +0900 | [diff] [blame] | 92 | add_text = nodes.strong(label, label) |
Georg Brandl | 495f7b5 | 2009-10-27 15:28:25 +0000 | [diff] [blame] | 93 | if self.arguments: |
| 94 | n, m = self.state.inline_text(self.arguments[0], self.lineno) |
| 95 | pnode.append(nodes.paragraph('', '', *(n + m))) |
| 96 | self.state.nested_parse(content, self.content_offset, pnode) |
| 97 | if pnode.children and isinstance(pnode[0], nodes.paragraph): |
INADA Naoki | c351ce6 | 2017-03-08 19:07:13 +0900 | [diff] [blame] | 98 | content = nodes.inline(pnode[0].rawsource, translatable=True) |
| 99 | content.source = pnode[0].source |
| 100 | content.line = pnode[0].line |
| 101 | content += pnode[0].children |
| 102 | pnode[0].replace_self(nodes.paragraph('', '', content, |
| 103 | translatable=False)) |
Georg Brandl | 495f7b5 | 2009-10-27 15:28:25 +0000 | [diff] [blame] | 104 | pnode[0].insert(0, add_text) |
| 105 | pnode[0].insert(1, nodes.Text(' ')) |
| 106 | else: |
| 107 | pnode.insert(0, nodes.paragraph('', '', add_text)) |
| 108 | return [pnode] |
| 109 | |
| 110 | |
Cheryl Sabella | 2d6097d | 2018-10-12 10:55:20 -0400 | [diff] [blame] | 111 | # Support for documenting platform availability |
| 112 | |
| 113 | class Availability(Directive): |
| 114 | |
| 115 | has_content = False |
| 116 | required_arguments = 1 |
| 117 | optional_arguments = 0 |
| 118 | final_argument_whitespace = True |
| 119 | |
| 120 | def run(self): |
Julien Palard | beed84c | 2018-11-07 22:42:40 +0100 | [diff] [blame] | 121 | availability_ref = ':ref:`Availability <availability>`: ' |
| 122 | pnode = nodes.paragraph(availability_ref + self.arguments[0], |
| 123 | classes=["availability"],) |
| 124 | n, m = self.state.inline_text(availability_ref, self.lineno) |
Cheryl Sabella | 2d6097d | 2018-10-12 10:55:20 -0400 | [diff] [blame] | 125 | pnode.extend(n + m) |
| 126 | n, m = self.state.inline_text(self.arguments[0], self.lineno) |
| 127 | pnode.extend(n + m) |
| 128 | return [pnode] |
| 129 | |
| 130 | |
Steve Dower | b82e17e | 2019-05-23 08:45:22 -0700 | [diff] [blame] | 131 | # Support for documenting audit event |
| 132 | |
Julien Palard | a103e73 | 2020-07-06 22:28:15 +0200 | [diff] [blame] | 133 | def audit_events_purge(app, env, docname): |
| 134 | """This is to remove from env.all_audit_events old traces of removed |
| 135 | documents. |
| 136 | """ |
| 137 | if not hasattr(env, 'all_audit_events'): |
| 138 | return |
| 139 | fresh_all_audit_events = {} |
| 140 | for name, event in env.all_audit_events.items(): |
| 141 | event["source"] = [(d, t) for d, t in event["source"] if d != docname] |
| 142 | if event["source"]: |
| 143 | # Only keep audit_events that have at least one source. |
| 144 | fresh_all_audit_events[name] = event |
| 145 | env.all_audit_events = fresh_all_audit_events |
| 146 | |
| 147 | |
| 148 | def audit_events_merge(app, env, docnames, other): |
| 149 | """In Sphinx parallel builds, this merges env.all_audit_events from |
| 150 | subprocesses. |
| 151 | |
| 152 | all_audit_events is a dict of names, with values like: |
| 153 | {'source': [(docname, target), ...], 'args': args} |
| 154 | """ |
| 155 | if not hasattr(other, 'all_audit_events'): |
| 156 | return |
| 157 | if not hasattr(env, 'all_audit_events'): |
| 158 | env.all_audit_events = {} |
| 159 | for name, value in other.all_audit_events.items(): |
| 160 | if name in env.all_audit_events: |
| 161 | env.all_audit_events[name]["source"].extend(value["source"]) |
| 162 | else: |
| 163 | env.all_audit_events[name] = value |
| 164 | |
| 165 | |
Steve Dower | b82e17e | 2019-05-23 08:45:22 -0700 | [diff] [blame] | 166 | class AuditEvent(Directive): |
| 167 | |
| 168 | has_content = True |
| 169 | required_arguments = 1 |
Steve Dower | 44f91c3 | 2019-06-27 10:47:59 -0700 | [diff] [blame] | 170 | optional_arguments = 2 |
Steve Dower | b82e17e | 2019-05-23 08:45:22 -0700 | [diff] [blame] | 171 | final_argument_whitespace = True |
| 172 | |
| 173 | _label = [ |
| 174 | "Raises an :ref:`auditing event <auditing>` {name} with no arguments.", |
| 175 | "Raises an :ref:`auditing event <auditing>` {name} with argument {args}.", |
| 176 | "Raises an :ref:`auditing event <auditing>` {name} with arguments {args}.", |
| 177 | ] |
| 178 | |
Steve Dower | 44f91c3 | 2019-06-27 10:47:59 -0700 | [diff] [blame] | 179 | @property |
| 180 | def logger(self): |
| 181 | cls = type(self) |
| 182 | return logging.getLogger(cls.__module__ + "." + cls.__name__) |
| 183 | |
Steve Dower | b82e17e | 2019-05-23 08:45:22 -0700 | [diff] [blame] | 184 | def run(self): |
Steve Dower | 44f91c3 | 2019-06-27 10:47:59 -0700 | [diff] [blame] | 185 | name = self.arguments[0] |
Steve Dower | b82e17e | 2019-05-23 08:45:22 -0700 | [diff] [blame] | 186 | if len(self.arguments) >= 2 and self.arguments[1]: |
Steve Dower | 44f91c3 | 2019-06-27 10:47:59 -0700 | [diff] [blame] | 187 | args = (a.strip() for a in self.arguments[1].strip("'\"").split(",")) |
| 188 | args = [a for a in args if a] |
Steve Dower | b82e17e | 2019-05-23 08:45:22 -0700 | [diff] [blame] | 189 | else: |
| 190 | args = [] |
| 191 | |
| 192 | label = translators['sphinx'].gettext(self._label[min(2, len(args))]) |
Steve Dower | 44f91c3 | 2019-06-27 10:47:59 -0700 | [diff] [blame] | 193 | text = label.format(name="``{}``".format(name), |
| 194 | args=", ".join("``{}``".format(a) for a in args if a)) |
Steve Dower | b82e17e | 2019-05-23 08:45:22 -0700 | [diff] [blame] | 195 | |
Steve Dower | 44f91c3 | 2019-06-27 10:47:59 -0700 | [diff] [blame] | 196 | env = self.state.document.settings.env |
| 197 | if not hasattr(env, 'all_audit_events'): |
| 198 | env.all_audit_events = {} |
| 199 | |
| 200 | new_info = { |
| 201 | 'source': [], |
| 202 | 'args': args |
| 203 | } |
| 204 | info = env.all_audit_events.setdefault(name, new_info) |
| 205 | if info is not new_info: |
| 206 | if not self._do_args_match(info['args'], new_info['args']): |
| 207 | self.logger.warn( |
| 208 | "Mismatched arguments for audit-event {}: {!r} != {!r}" |
| 209 | .format(name, info['args'], new_info['args']) |
| 210 | ) |
| 211 | |
Steve Dower | e226e83 | 2019-07-01 16:03:53 -0700 | [diff] [blame] | 212 | ids = [] |
| 213 | try: |
| 214 | target = self.arguments[2].strip("\"'") |
| 215 | except (IndexError, TypeError): |
| 216 | target = None |
| 217 | if not target: |
| 218 | target = "audit_event_{}_{}".format( |
| 219 | re.sub(r'\W', '_', name), |
| 220 | len(info['source']), |
| 221 | ) |
| 222 | ids.append(target) |
| 223 | |
Steve Dower | 44f91c3 | 2019-06-27 10:47:59 -0700 | [diff] [blame] | 224 | info['source'].append((env.docname, target)) |
| 225 | |
| 226 | pnode = nodes.paragraph(text, classes=["audit-hook"], ids=ids) |
Jules Lasne | dbfabcc | 2021-03-01 22:59:58 +0100 | [diff] [blame] | 227 | pnode.line = self.lineno |
Steve Dower | b82e17e | 2019-05-23 08:45:22 -0700 | [diff] [blame] | 228 | if self.content: |
| 229 | self.state.nested_parse(self.content, self.content_offset, pnode) |
| 230 | else: |
| 231 | n, m = self.state.inline_text(text, self.lineno) |
| 232 | pnode.extend(n + m) |
| 233 | |
| 234 | return [pnode] |
| 235 | |
Steve Dower | 44f91c3 | 2019-06-27 10:47:59 -0700 | [diff] [blame] | 236 | # This list of sets are allowable synonyms for event argument names. |
| 237 | # If two names are in the same set, they are treated as equal for the |
| 238 | # purposes of warning. This won't help if number of arguments is |
| 239 | # different! |
| 240 | _SYNONYMS = [ |
| 241 | {"file", "path", "fd"}, |
| 242 | ] |
| 243 | |
| 244 | def _do_args_match(self, args1, args2): |
| 245 | if args1 == args2: |
| 246 | return True |
| 247 | if len(args1) != len(args2): |
| 248 | return False |
| 249 | for a1, a2 in zip(args1, args2): |
| 250 | if a1 == a2: |
| 251 | continue |
| 252 | if any(a1 in s and a2 in s for s in self._SYNONYMS): |
| 253 | continue |
| 254 | return False |
| 255 | return True |
| 256 | |
| 257 | |
| 258 | class audit_event_list(nodes.General, nodes.Element): |
| 259 | pass |
| 260 | |
| 261 | |
| 262 | class AuditEventListDirective(Directive): |
| 263 | |
| 264 | def run(self): |
| 265 | return [audit_event_list('')] |
| 266 | |
Steve Dower | b82e17e | 2019-05-23 08:45:22 -0700 | [diff] [blame] | 267 | |
Georg Brandl | 8a1caa2 | 2010-07-29 16:01:11 +0000 | [diff] [blame] | 268 | # Support for documenting decorators |
| 269 | |
Georg Brandl | 8a1caa2 | 2010-07-29 16:01:11 +0000 | [diff] [blame] | 270 | class PyDecoratorMixin(object): |
| 271 | def handle_signature(self, sig, signode): |
| 272 | ret = super(PyDecoratorMixin, self).handle_signature(sig, signode) |
| 273 | signode.insert(0, addnodes.desc_addname('@', '@')) |
| 274 | return ret |
| 275 | |
| 276 | def needs_arglist(self): |
| 277 | return False |
| 278 | |
Georg Brandl | 35903c8 | 2014-10-30 22:55:13 +0100 | [diff] [blame] | 279 | |
Dong-hee Na | 6595cb0 | 2020-09-18 18:22:36 +0900 | [diff] [blame] | 280 | class PyDecoratorFunction(PyDecoratorMixin, PyFunction): |
Georg Brandl | 8a1caa2 | 2010-07-29 16:01:11 +0000 | [diff] [blame] | 281 | def run(self): |
| 282 | # a decorator function is a function after all |
| 283 | self.name = 'py:function' |
Dong-hee Na | 6595cb0 | 2020-09-18 18:22:36 +0900 | [diff] [blame] | 284 | return PyFunction.run(self) |
Georg Brandl | 8a1caa2 | 2010-07-29 16:01:11 +0000 | [diff] [blame] | 285 | |
Georg Brandl | 35903c8 | 2014-10-30 22:55:13 +0100 | [diff] [blame] | 286 | |
Dong-hee Na | 6595cb0 | 2020-09-18 18:22:36 +0900 | [diff] [blame] | 287 | # TODO: Use sphinx.domains.python.PyDecoratorMethod when possible |
| 288 | class PyDecoratorMethod(PyDecoratorMixin, PyMethod): |
Georg Brandl | 8a1caa2 | 2010-07-29 16:01:11 +0000 | [diff] [blame] | 289 | def run(self): |
| 290 | self.name = 'py:method' |
Dong-hee Na | 6595cb0 | 2020-09-18 18:22:36 +0900 | [diff] [blame] | 291 | return PyMethod.run(self) |
Georg Brandl | 8a1caa2 | 2010-07-29 16:01:11 +0000 | [diff] [blame] | 292 | |
| 293 | |
Victor Stinner | bdd574d | 2015-02-12 22:49:18 +0100 | [diff] [blame] | 294 | class PyCoroutineMixin(object): |
| 295 | def handle_signature(self, sig, signode): |
| 296 | ret = super(PyCoroutineMixin, self).handle_signature(sig, signode) |
Victor Stinner | bdd574d | 2015-02-12 22:49:18 +0100 | [diff] [blame] | 297 | signode.insert(0, addnodes.desc_annotation('coroutine ', 'coroutine ')) |
| 298 | return ret |
| 299 | |
Victor Stinner | bdd574d | 2015-02-12 22:49:18 +0100 | [diff] [blame] | 300 | |
Yury Selivanov | 4715039 | 2018-09-18 17:55:44 -0400 | [diff] [blame] | 301 | class PyAwaitableMixin(object): |
| 302 | def handle_signature(self, sig, signode): |
| 303 | ret = super(PyAwaitableMixin, self).handle_signature(sig, signode) |
| 304 | signode.insert(0, addnodes.desc_annotation('awaitable ', 'awaitable ')) |
| 305 | return ret |
| 306 | |
| 307 | |
Dong-hee Na | 6595cb0 | 2020-09-18 18:22:36 +0900 | [diff] [blame] | 308 | class PyCoroutineFunction(PyCoroutineMixin, PyFunction): |
Victor Stinner | bdd574d | 2015-02-12 22:49:18 +0100 | [diff] [blame] | 309 | def run(self): |
Victor Stinner | bdd574d | 2015-02-12 22:49:18 +0100 | [diff] [blame] | 310 | self.name = 'py:function' |
Dong-hee Na | 6595cb0 | 2020-09-18 18:22:36 +0900 | [diff] [blame] | 311 | return PyFunction.run(self) |
Victor Stinner | bdd574d | 2015-02-12 22:49:18 +0100 | [diff] [blame] | 312 | |
| 313 | |
Dong-hee Na | 6595cb0 | 2020-09-18 18:22:36 +0900 | [diff] [blame] | 314 | class PyCoroutineMethod(PyCoroutineMixin, PyMethod): |
Victor Stinner | bdd574d | 2015-02-12 22:49:18 +0100 | [diff] [blame] | 315 | def run(self): |
| 316 | self.name = 'py:method' |
Dong-hee Na | 6595cb0 | 2020-09-18 18:22:36 +0900 | [diff] [blame] | 317 | return PyMethod.run(self) |
Victor Stinner | bdd574d | 2015-02-12 22:49:18 +0100 | [diff] [blame] | 318 | |
| 319 | |
Dong-hee Na | 6595cb0 | 2020-09-18 18:22:36 +0900 | [diff] [blame] | 320 | class PyAwaitableFunction(PyAwaitableMixin, PyFunction): |
Yury Selivanov | 4715039 | 2018-09-18 17:55:44 -0400 | [diff] [blame] | 321 | def run(self): |
| 322 | self.name = 'py:function' |
Dong-hee Na | 6595cb0 | 2020-09-18 18:22:36 +0900 | [diff] [blame] | 323 | return PyFunction.run(self) |
Yury Selivanov | 4715039 | 2018-09-18 17:55:44 -0400 | [diff] [blame] | 324 | |
| 325 | |
Dong-hee Na | 6595cb0 | 2020-09-18 18:22:36 +0900 | [diff] [blame] | 326 | class PyAwaitableMethod(PyAwaitableMixin, PyMethod): |
Yury Selivanov | 4715039 | 2018-09-18 17:55:44 -0400 | [diff] [blame] | 327 | def run(self): |
| 328 | self.name = 'py:method' |
Dong-hee Na | 6595cb0 | 2020-09-18 18:22:36 +0900 | [diff] [blame] | 329 | return PyMethod.run(self) |
Yury Selivanov | 4715039 | 2018-09-18 17:55:44 -0400 | [diff] [blame] | 330 | |
| 331 | |
Dong-hee Na | 6595cb0 | 2020-09-18 18:22:36 +0900 | [diff] [blame] | 332 | class PyAbstractMethod(PyMethod): |
Berker Peksag | 6e9d2e6 | 2015-12-08 12:14:50 +0200 | [diff] [blame] | 333 | |
| 334 | def handle_signature(self, sig, signode): |
| 335 | ret = super(PyAbstractMethod, self).handle_signature(sig, signode) |
| 336 | signode.insert(0, addnodes.desc_annotation('abstractmethod ', |
| 337 | 'abstractmethod ')) |
| 338 | return ret |
| 339 | |
| 340 | def run(self): |
| 341 | self.name = 'py:method' |
Dong-hee Na | 6595cb0 | 2020-09-18 18:22:36 +0900 | [diff] [blame] | 342 | return PyMethod.run(self) |
Berker Peksag | 6e9d2e6 | 2015-12-08 12:14:50 +0200 | [diff] [blame] | 343 | |
| 344 | |
Georg Brandl | 281d6ba | 2010-11-12 08:57:12 +0000 | [diff] [blame] | 345 | # Support for documenting version of removal in deprecations |
| 346 | |
Georg Brandl | 281d6ba | 2010-11-12 08:57:12 +0000 | [diff] [blame] | 347 | class DeprecatedRemoved(Directive): |
| 348 | has_content = True |
| 349 | required_arguments = 2 |
| 350 | optional_arguments = 1 |
| 351 | final_argument_whitespace = True |
| 352 | option_spec = {} |
| 353 | |
Florian Dahlitz | 735d902 | 2020-05-30 09:47:32 +0200 | [diff] [blame] | 354 | _deprecated_label = 'Deprecated since version {deprecated}, will be removed in version {removed}' |
| 355 | _removed_label = 'Deprecated since version {deprecated}, removed in version {removed}' |
Georg Brandl | 7ed509a | 2014-01-21 19:20:31 +0100 | [diff] [blame] | 356 | |
Georg Brandl | 281d6ba | 2010-11-12 08:57:12 +0000 | [diff] [blame] | 357 | def run(self): |
| 358 | node = addnodes.versionmodified() |
| 359 | node.document = self.state.document |
| 360 | node['type'] = 'deprecated-removed' |
| 361 | version = (self.arguments[0], self.arguments[1]) |
| 362 | node['version'] = version |
Florian Dahlitz | 735d902 | 2020-05-30 09:47:32 +0200 | [diff] [blame] | 363 | env = self.state.document.settings.env |
| 364 | current_version = tuple(int(e) for e in env.config.version.split('.')) |
| 365 | removed_version = tuple(int(e) for e in self.arguments[1].split('.')) |
| 366 | if current_version < removed_version: |
| 367 | label = self._deprecated_label |
| 368 | else: |
| 369 | label = self._removed_label |
| 370 | |
| 371 | label = translators['sphinx'].gettext(label) |
cocoatomo | 0febc05 | 2018-02-23 20:47:19 +0900 | [diff] [blame] | 372 | text = label.format(deprecated=self.arguments[0], removed=self.arguments[1]) |
Georg Brandl | 281d6ba | 2010-11-12 08:57:12 +0000 | [diff] [blame] | 373 | if len(self.arguments) == 3: |
| 374 | inodes, messages = self.state.inline_text(self.arguments[2], |
| 375 | self.lineno+1) |
cocoatomo | 0febc05 | 2018-02-23 20:47:19 +0900 | [diff] [blame] | 376 | para = nodes.paragraph(self.arguments[2], '', *inodes, translatable=False) |
Georg Brandl | 7ed509a | 2014-01-21 19:20:31 +0100 | [diff] [blame] | 377 | node.append(para) |
Georg Brandl | 281d6ba | 2010-11-12 08:57:12 +0000 | [diff] [blame] | 378 | else: |
Georg Brandl | 7ed509a | 2014-01-21 19:20:31 +0100 | [diff] [blame] | 379 | messages = [] |
| 380 | if self.content: |
| 381 | self.state.nested_parse(self.content, self.content_offset, node) |
Berker Peksag | eb1a3cd | 2014-11-08 22:40:22 +0200 | [diff] [blame] | 382 | if len(node): |
Georg Brandl | 7ed509a | 2014-01-21 19:20:31 +0100 | [diff] [blame] | 383 | if isinstance(node[0], nodes.paragraph) and node[0].rawsource: |
| 384 | content = nodes.inline(node[0].rawsource, translatable=True) |
| 385 | content.source = node[0].source |
| 386 | content.line = node[0].line |
| 387 | content += node[0].children |
cocoatomo | 0febc05 | 2018-02-23 20:47:19 +0900 | [diff] [blame] | 388 | node[0].replace_self(nodes.paragraph('', '', content, translatable=False)) |
Berker Peksag | eb1a3cd | 2014-11-08 22:40:22 +0200 | [diff] [blame] | 389 | node[0].insert(0, nodes.inline('', '%s: ' % text, |
| 390 | classes=['versionmodified'])) |
Ned Deily | b682fd3 | 2014-09-22 14:44:22 -0700 | [diff] [blame] | 391 | else: |
Georg Brandl | 7ed509a | 2014-01-21 19:20:31 +0100 | [diff] [blame] | 392 | para = nodes.paragraph('', '', |
Georg Brandl | 35903c8 | 2014-10-30 22:55:13 +0100 | [diff] [blame] | 393 | nodes.inline('', '%s.' % text, |
cocoatomo | 0febc05 | 2018-02-23 20:47:19 +0900 | [diff] [blame] | 394 | classes=['versionmodified']), |
| 395 | translatable=False) |
Berker Peksag | eb1a3cd | 2014-11-08 22:40:22 +0200 | [diff] [blame] | 396 | node.append(para) |
Georg Brandl | 281d6ba | 2010-11-12 08:57:12 +0000 | [diff] [blame] | 397 | env = self.state.document.settings.env |
Matěj Cepl | b63a620 | 2020-12-07 21:05:13 +0100 | [diff] [blame] | 398 | # deprecated pre-Sphinx-2 method |
| 399 | if hasattr(env, 'note_versionchange'): |
| 400 | env.note_versionchange('deprecated', version[0], node, self.lineno) |
| 401 | # new method |
| 402 | else: |
| 403 | env.get_domain('changeset').note_changeset(node) |
Georg Brandl | 7ed509a | 2014-01-21 19:20:31 +0100 | [diff] [blame] | 404 | return [node] + messages |
Georg Brandl | 281d6ba | 2010-11-12 08:57:12 +0000 | [diff] [blame] | 405 | |
| 406 | |
Georg Brandl | 2cac28b | 2012-09-30 15:10:06 +0200 | [diff] [blame] | 407 | # Support for including Misc/NEWS |
| 408 | |
Brett Cannon | 79ab8be | 2017-02-10 15:10:13 -0800 | [diff] [blame] | 409 | issue_re = re.compile('(?:[Ii]ssue #|bpo-)([0-9]+)') |
Georg Brandl | 44d0c21 | 2012-10-01 19:08:50 +0200 | [diff] [blame] | 410 | whatsnew_re = re.compile(r"(?im)^what's new in (.*?)\??$") |
Georg Brandl | 2cac28b | 2012-09-30 15:10:06 +0200 | [diff] [blame] | 411 | |
Georg Brandl | 35903c8 | 2014-10-30 22:55:13 +0100 | [diff] [blame] | 412 | |
Georg Brandl | 2cac28b | 2012-09-30 15:10:06 +0200 | [diff] [blame] | 413 | class MiscNews(Directive): |
| 414 | has_content = False |
| 415 | required_arguments = 1 |
| 416 | optional_arguments = 0 |
| 417 | final_argument_whitespace = False |
| 418 | option_spec = {} |
| 419 | |
| 420 | def run(self): |
| 421 | fname = self.arguments[0] |
| 422 | source = self.state_machine.input_lines.source( |
| 423 | self.lineno - self.state_machine.input_offset - 1) |
Steve Dower | afe17a7 | 2018-12-19 18:20:06 -0800 | [diff] [blame] | 424 | source_dir = getenv('PY_MISC_NEWS_DIR') |
| 425 | if not source_dir: |
| 426 | source_dir = path.dirname(path.abspath(source)) |
Georg Brandl | 44d0c21 | 2012-10-01 19:08:50 +0200 | [diff] [blame] | 427 | fpath = path.join(source_dir, fname) |
| 428 | self.state.document.settings.record_dependencies.add(fpath) |
Georg Brandl | 2cac28b | 2012-09-30 15:10:06 +0200 | [diff] [blame] | 429 | try: |
Victor Stinner | 272d888 | 2017-06-16 08:59:01 +0200 | [diff] [blame] | 430 | with io.open(fpath, encoding='utf-8') as fp: |
Georg Brandl | 2cac28b | 2012-09-30 15:10:06 +0200 | [diff] [blame] | 431 | content = fp.read() |
Georg Brandl | 2cac28b | 2012-09-30 15:10:06 +0200 | [diff] [blame] | 432 | except Exception: |
| 433 | text = 'The NEWS file is not available.' |
| 434 | node = nodes.strong(text, text) |
| 435 | return [node] |
Brett Cannon | 79ab8be | 2017-02-10 15:10:13 -0800 | [diff] [blame] | 436 | content = issue_re.sub(r'`bpo-\1 <https://bugs.python.org/issue\1>`__', |
Georg Brandl | 2cac28b | 2012-09-30 15:10:06 +0200 | [diff] [blame] | 437 | content) |
Georg Brandl | 44d0c21 | 2012-10-01 19:08:50 +0200 | [diff] [blame] | 438 | content = whatsnew_re.sub(r'\1', content) |
Georg Brandl | 2cac28b | 2012-09-30 15:10:06 +0200 | [diff] [blame] | 439 | # remove first 3 lines as they are the main heading |
Georg Brandl | 6c47581 | 2012-10-01 19:27:05 +0200 | [diff] [blame] | 440 | lines = ['.. default-role:: obj', ''] + content.splitlines()[3:] |
Georg Brandl | 2cac28b | 2012-09-30 15:10:06 +0200 | [diff] [blame] | 441 | self.state_machine.insert_input(lines, fname) |
| 442 | return [] |
| 443 | |
| 444 | |
Georg Brandl | 6b38daa | 2008-06-01 21:05:17 +0000 | [diff] [blame] | 445 | # Support for building "topic help" for pydoc |
| 446 | |
| 447 | pydoc_topic_labels = [ |
Jelle Zijlstra | ac31770 | 2017-10-05 20:24:46 -0700 | [diff] [blame] | 448 | 'assert', 'assignment', 'async', 'atom-identifiers', 'atom-literals', |
| 449 | 'attribute-access', 'attribute-references', 'augassign', 'await', |
| 450 | 'binary', 'bitwise', 'bltin-code-objects', 'bltin-ellipsis-object', |
Benjamin Peterson | 0d31d58 | 2010-06-06 02:44:41 +0000 | [diff] [blame] | 451 | 'bltin-null-object', 'bltin-type-objects', 'booleans', |
Georg Brandl | 6b38daa | 2008-06-01 21:05:17 +0000 | [diff] [blame] | 452 | 'break', 'callable-types', 'calls', 'class', 'comparisons', 'compound', |
| 453 | 'context-managers', 'continue', 'conversions', 'customization', 'debugger', |
| 454 | 'del', 'dict', 'dynamic-features', 'else', 'exceptions', 'execmodel', |
| 455 | 'exprlists', 'floating', 'for', 'formatstrings', 'function', 'global', |
| 456 | 'id-classes', 'identifiers', 'if', 'imaginary', 'import', 'in', 'integers', |
Benjamin Peterson | f5a3d69 | 2010-08-31 14:31:01 +0000 | [diff] [blame] | 457 | 'lambda', 'lists', 'naming', 'nonlocal', 'numbers', 'numeric-types', |
| 458 | 'objects', 'operator-summary', 'pass', 'power', 'raise', 'return', |
| 459 | 'sequence-types', 'shifting', 'slicings', 'specialattrs', 'specialnames', |
| 460 | 'string-methods', 'strings', 'subscriptions', 'truth', 'try', 'types', |
| 461 | 'typesfunctions', 'typesmapping', 'typesmethods', 'typesmodules', |
| 462 | 'typesseq', 'typesseq-mutable', 'unary', 'while', 'with', 'yield' |
Georg Brandl | 6b38daa | 2008-06-01 21:05:17 +0000 | [diff] [blame] | 463 | ] |
| 464 | |
Georg Brandl | 6b38daa | 2008-06-01 21:05:17 +0000 | [diff] [blame] | 465 | |
| 466 | class PydocTopicsBuilder(Builder): |
| 467 | name = 'pydoc-topics' |
| 468 | |
Benjamin Peterson | acfb087 | 2018-04-16 22:56:46 -0700 | [diff] [blame] | 469 | default_translator_class = TextTranslator |
| 470 | |
Georg Brandl | 6b38daa | 2008-06-01 21:05:17 +0000 | [diff] [blame] | 471 | def init(self): |
| 472 | self.topics = {} |
Benjamin Peterson | acfb087 | 2018-04-16 22:56:46 -0700 | [diff] [blame] | 473 | self.secnumbers = {} |
Georg Brandl | 6b38daa | 2008-06-01 21:05:17 +0000 | [diff] [blame] | 474 | |
| 475 | def get_outdated_docs(self): |
| 476 | return 'all pydoc topics' |
| 477 | |
| 478 | def get_target_uri(self, docname, typ=None): |
| 479 | return '' # no URIs |
| 480 | |
| 481 | def write(self, *ignored): |
| 482 | writer = TextWriter(self) |
Benjamin Peterson | acfb087 | 2018-04-16 22:56:46 -0700 | [diff] [blame] | 483 | for label in status_iterator(pydoc_topic_labels, |
| 484 | 'building topics... ', |
| 485 | length=len(pydoc_topic_labels)): |
Georg Brandl | 80ff2ad | 2010-07-31 08:27:46 +0000 | [diff] [blame] | 486 | if label not in self.env.domaindata['std']['labels']: |
Steve Dower | 44f91c3 | 2019-06-27 10:47:59 -0700 | [diff] [blame] | 487 | self.env.logger.warn('label %r not in documentation' % label) |
Georg Brandl | 6b38daa | 2008-06-01 21:05:17 +0000 | [diff] [blame] | 488 | continue |
Georg Brandl | 80ff2ad | 2010-07-31 08:27:46 +0000 | [diff] [blame] | 489 | docname, labelid, sectname = self.env.domaindata['std']['labels'][label] |
Georg Brandl | 6b38daa | 2008-06-01 21:05:17 +0000 | [diff] [blame] | 490 | doctree = self.env.get_and_resolve_doctree(docname, self) |
| 491 | document = new_document('<section node>') |
| 492 | document.append(doctree.ids[labelid]) |
| 493 | destination = StringOutput(encoding='utf-8') |
| 494 | writer.write(document, destination) |
Ned Deily | b682fd3 | 2014-09-22 14:44:22 -0700 | [diff] [blame] | 495 | self.topics[label] = writer.output |
Georg Brandl | 6b38daa | 2008-06-01 21:05:17 +0000 | [diff] [blame] | 496 | |
| 497 | def finish(self): |
Ned Deily | b682fd3 | 2014-09-22 14:44:22 -0700 | [diff] [blame] | 498 | f = open(path.join(self.outdir, 'topics.py'), 'wb') |
Georg Brandl | 6b38daa | 2008-06-01 21:05:17 +0000 | [diff] [blame] | 499 | try: |
Ned Deily | b682fd3 | 2014-09-22 14:44:22 -0700 | [diff] [blame] | 500 | f.write('# -*- coding: utf-8 -*-\n'.encode('utf-8')) |
| 501 | f.write(('# Autogenerated by Sphinx on %s\n' % asctime()).encode('utf-8')) |
| 502 | f.write(('topics = ' + pformat(self.topics) + '\n').encode('utf-8')) |
Georg Brandl | 6b38daa | 2008-06-01 21:05:17 +0000 | [diff] [blame] | 503 | finally: |
| 504 | f.close() |
| 505 | |
Georg Brandl | 495f7b5 | 2009-10-27 15:28:25 +0000 | [diff] [blame] | 506 | |
Georg Brandl | f0dd6a6 | 2008-07-23 15:19:11 +0000 | [diff] [blame] | 507 | # Support for documenting Opcodes |
| 508 | |
Georg Brandl | 4833e5b | 2010-07-03 10:41:33 +0000 | [diff] [blame] | 509 | opcode_sig_re = re.compile(r'(\w+(?:\+\d)?)(?:\s*\((.*)\))?') |
Georg Brandl | f0dd6a6 | 2008-07-23 15:19:11 +0000 | [diff] [blame] | 510 | |
Georg Brandl | 35903c8 | 2014-10-30 22:55:13 +0100 | [diff] [blame] | 511 | |
Georg Brandl | f0dd6a6 | 2008-07-23 15:19:11 +0000 | [diff] [blame] | 512 | def parse_opcode_signature(env, sig, signode): |
| 513 | """Transform an opcode signature into RST nodes.""" |
| 514 | m = opcode_sig_re.match(sig) |
| 515 | if m is None: |
| 516 | raise ValueError |
| 517 | opname, arglist = m.groups() |
| 518 | signode += addnodes.desc_name(opname, opname) |
Georg Brandl | 4833e5b | 2010-07-03 10:41:33 +0000 | [diff] [blame] | 519 | if arglist is not None: |
| 520 | paramlist = addnodes.desc_parameterlist() |
| 521 | signode += paramlist |
| 522 | paramlist += addnodes.desc_parameter(arglist, arglist) |
Georg Brandl | f0dd6a6 | 2008-07-23 15:19:11 +0000 | [diff] [blame] | 523 | return opname.strip() |
| 524 | |
| 525 | |
Georg Brandl | 281d6ba | 2010-11-12 08:57:12 +0000 | [diff] [blame] | 526 | # Support for documenting pdb commands |
| 527 | |
Georg Brandl | 02053ee | 2010-07-18 10:11:03 +0000 | [diff] [blame] | 528 | pdbcmd_sig_re = re.compile(r'([a-z()!]+)\s*(.*)') |
| 529 | |
| 530 | # later... |
Georg Brandl | 35903c8 | 2014-10-30 22:55:13 +0100 | [diff] [blame] | 531 | # pdbargs_tokens_re = re.compile(r'''[a-zA-Z]+ | # identifiers |
Georg Brandl | 02053ee | 2010-07-18 10:11:03 +0000 | [diff] [blame] | 532 | # [.,:]+ | # punctuation |
| 533 | # [\[\]()] | # parens |
| 534 | # \s+ # whitespace |
| 535 | # ''', re.X) |
| 536 | |
Georg Brandl | 35903c8 | 2014-10-30 22:55:13 +0100 | [diff] [blame] | 537 | |
Georg Brandl | 02053ee | 2010-07-18 10:11:03 +0000 | [diff] [blame] | 538 | def parse_pdb_command(env, sig, signode): |
| 539 | """Transform a pdb command signature into RST nodes.""" |
| 540 | m = pdbcmd_sig_re.match(sig) |
| 541 | if m is None: |
| 542 | raise ValueError |
| 543 | name, args = m.groups() |
| 544 | fullname = name.replace('(', '').replace(')', '') |
| 545 | signode += addnodes.desc_name(name, name) |
| 546 | if args: |
| 547 | signode += addnodes.desc_addname(' '+args, ' '+args) |
| 548 | return fullname |
| 549 | |
| 550 | |
Steve Dower | 44f91c3 | 2019-06-27 10:47:59 -0700 | [diff] [blame] | 551 | def process_audit_events(app, doctree, fromdocname): |
| 552 | for node in doctree.traverse(audit_event_list): |
| 553 | break |
| 554 | else: |
| 555 | return |
| 556 | |
| 557 | env = app.builder.env |
| 558 | |
| 559 | table = nodes.table(cols=3) |
| 560 | group = nodes.tgroup( |
| 561 | '', |
| 562 | nodes.colspec(colwidth=30), |
| 563 | nodes.colspec(colwidth=55), |
| 564 | nodes.colspec(colwidth=15), |
Dmitry Shachnev | c3d679f | 2019-09-10 17:40:50 +0300 | [diff] [blame] | 565 | cols=3, |
Steve Dower | 44f91c3 | 2019-06-27 10:47:59 -0700 | [diff] [blame] | 566 | ) |
| 567 | head = nodes.thead() |
| 568 | body = nodes.tbody() |
| 569 | |
| 570 | table += group |
| 571 | group += head |
| 572 | group += body |
| 573 | |
| 574 | row = nodes.row() |
| 575 | row += nodes.entry('', nodes.paragraph('', nodes.Text('Audit event'))) |
| 576 | row += nodes.entry('', nodes.paragraph('', nodes.Text('Arguments'))) |
| 577 | row += nodes.entry('', nodes.paragraph('', nodes.Text('References'))) |
| 578 | head += row |
| 579 | |
| 580 | for name in sorted(getattr(env, "all_audit_events", ())): |
| 581 | audit_event = env.all_audit_events[name] |
| 582 | |
| 583 | row = nodes.row() |
| 584 | node = nodes.paragraph('', nodes.Text(name)) |
| 585 | row += nodes.entry('', node) |
| 586 | |
| 587 | node = nodes.paragraph() |
| 588 | for i, a in enumerate(audit_event['args']): |
| 589 | if i: |
| 590 | node += nodes.Text(", ") |
| 591 | node += nodes.literal(a, nodes.Text(a)) |
| 592 | row += nodes.entry('', node) |
| 593 | |
| 594 | node = nodes.paragraph() |
Steve Dower | e226e83 | 2019-07-01 16:03:53 -0700 | [diff] [blame] | 595 | backlinks = enumerate(sorted(set(audit_event['source'])), start=1) |
| 596 | for i, (doc, label) in backlinks: |
Steve Dower | 44f91c3 | 2019-06-27 10:47:59 -0700 | [diff] [blame] | 597 | if isinstance(label, str): |
| 598 | ref = nodes.reference("", nodes.Text("[{}]".format(i)), internal=True) |
Julien Palard | 63c98ed | 2019-09-09 12:54:56 +0200 | [diff] [blame] | 599 | try: |
| 600 | ref['refuri'] = "{}#{}".format( |
| 601 | app.builder.get_relative_uri(fromdocname, doc), |
| 602 | label, |
| 603 | ) |
| 604 | except NoUri: |
| 605 | continue |
Steve Dower | 44f91c3 | 2019-06-27 10:47:59 -0700 | [diff] [blame] | 606 | node += ref |
| 607 | row += nodes.entry('', node) |
| 608 | |
| 609 | body += row |
| 610 | |
| 611 | for node in doctree.traverse(audit_event_list): |
| 612 | node.replace_self(table) |
| 613 | |
| 614 | |
Martin v. Löwis | 5680d0c | 2008-04-10 03:06:53 +0000 | [diff] [blame] | 615 | def setup(app): |
| 616 | app.add_role('issue', issue_role) |
Georg Brandl | 6881886 | 2010-11-06 07:19:35 +0000 | [diff] [blame] | 617 | app.add_role('source', source_role) |
Georg Brandl | 495f7b5 | 2009-10-27 15:28:25 +0000 | [diff] [blame] | 618 | app.add_directive('impl-detail', ImplementationDetail) |
Cheryl Sabella | 2d6097d | 2018-10-12 10:55:20 -0400 | [diff] [blame] | 619 | app.add_directive('availability', Availability) |
Steve Dower | b82e17e | 2019-05-23 08:45:22 -0700 | [diff] [blame] | 620 | app.add_directive('audit-event', AuditEvent) |
Steve Dower | 44f91c3 | 2019-06-27 10:47:59 -0700 | [diff] [blame] | 621 | app.add_directive('audit-event-table', AuditEventListDirective) |
Georg Brandl | 281d6ba | 2010-11-12 08:57:12 +0000 | [diff] [blame] | 622 | app.add_directive('deprecated-removed', DeprecatedRemoved) |
Georg Brandl | 6b38daa | 2008-06-01 21:05:17 +0000 | [diff] [blame] | 623 | app.add_builder(PydocTopicsBuilder) |
Benjamin Peterson | 28d88b4 | 2009-01-09 03:03:23 +0000 | [diff] [blame] | 624 | app.add_builder(suspicious.CheckSuspiciousMarkupBuilder) |
Stéphane Wirtel | e385d06 | 2018-10-13 08:14:08 +0200 | [diff] [blame] | 625 | app.add_object_type('opcode', 'opcode', '%s (opcode)', parse_opcode_signature) |
| 626 | app.add_object_type('pdbcommand', 'pdbcmd', '%s (pdb command)', parse_pdb_command) |
| 627 | app.add_object_type('2to3fixer', '2to3fixer', '%s (2to3 fixer)') |
Georg Brandl | 8a1caa2 | 2010-07-29 16:01:11 +0000 | [diff] [blame] | 628 | app.add_directive_to_domain('py', 'decorator', PyDecoratorFunction) |
| 629 | app.add_directive_to_domain('py', 'decoratormethod', PyDecoratorMethod) |
Victor Stinner | bdd574d | 2015-02-12 22:49:18 +0100 | [diff] [blame] | 630 | app.add_directive_to_domain('py', 'coroutinefunction', PyCoroutineFunction) |
| 631 | app.add_directive_to_domain('py', 'coroutinemethod', PyCoroutineMethod) |
Yury Selivanov | 4715039 | 2018-09-18 17:55:44 -0400 | [diff] [blame] | 632 | app.add_directive_to_domain('py', 'awaitablefunction', PyAwaitableFunction) |
| 633 | app.add_directive_to_domain('py', 'awaitablemethod', PyAwaitableMethod) |
Berker Peksag | 6e9d2e6 | 2015-12-08 12:14:50 +0200 | [diff] [blame] | 634 | app.add_directive_to_domain('py', 'abstractmethod', PyAbstractMethod) |
Georg Brandl | 2cac28b | 2012-09-30 15:10:06 +0200 | [diff] [blame] | 635 | app.add_directive('miscnews', MiscNews) |
Steve Dower | 44f91c3 | 2019-06-27 10:47:59 -0700 | [diff] [blame] | 636 | app.connect('doctree-resolved', process_audit_events) |
Julien Palard | a103e73 | 2020-07-06 22:28:15 +0200 | [diff] [blame] | 637 | app.connect('env-merge-info', audit_events_merge) |
| 638 | app.connect('env-purge-doc', audit_events_purge) |
Georg Brandl | bae334c | 2014-09-30 22:17:41 +0200 | [diff] [blame] | 639 | return {'version': '1.0', 'parallel_read_safe': True} |