2008-04-10 00:06:53 -03:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
pyspecific.py
|
|
|
|
~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Sphinx extension with Python doc-specific markup.
|
|
|
|
|
2014-01-21 14:20:31 -04:00
|
|
|
:copyright: 2008-2014 by Georg Brandl.
|
2008-04-10 00:06:53 -03:00
|
|
|
:license: Python license.
|
|
|
|
"""
|
|
|
|
|
2014-10-30 18:55:13 -03:00
|
|
|
import re
|
2017-06-16 03:59:01 -03:00
|
|
|
import io
|
2018-12-19 22:20:06 -04:00
|
|
|
from os import getenv, path
|
2014-10-30 18:55:13 -03:00
|
|
|
from time import asctime
|
|
|
|
from pprint import pformat
|
|
|
|
from docutils.io import StringOutput
|
2017-07-15 16:28:02 -03:00
|
|
|
from docutils.parsers.rst import Directive
|
2014-10-30 18:55:13 -03:00
|
|
|
from docutils.utils import new_document
|
2008-04-10 00:06:53 -03:00
|
|
|
|
|
|
|
from docutils import nodes, utils
|
2013-10-12 15:50:21 -03:00
|
|
|
|
2014-10-30 18:55:13 -03:00
|
|
|
from sphinx import addnodes
|
|
|
|
from sphinx.builders import Builder
|
2019-09-09 07:54:56 -03:00
|
|
|
try:
|
|
|
|
from sphinx.errors import NoUri
|
|
|
|
except ImportError:
|
|
|
|
from sphinx.environment import NoUri
|
2017-03-08 06:07:13 -04:00
|
|
|
from sphinx.locale import translators
|
2019-06-27 14:47:59 -03:00
|
|
|
from sphinx.util import status_iterator, logging
|
2010-11-06 04:19:35 -03:00
|
|
|
from sphinx.util.nodes import split_explicit_title
|
2018-04-17 02:56:46 -03:00
|
|
|
from sphinx.writers.text import TextWriter, TextTranslator
|
2013-10-12 15:50:21 -03:00
|
|
|
from sphinx.writers.latex import LaTeXTranslator
|
2020-09-18 06:22:36 -03:00
|
|
|
|
|
|
|
try:
|
|
|
|
from sphinx.domains.python import PyFunction, PyMethod
|
|
|
|
except ImportError:
|
|
|
|
from sphinx.domains.python import PyClassmember as PyMethod
|
|
|
|
from sphinx.domains.python import PyModulelevel as PyFunction
|
2014-10-30 18:55:13 -03:00
|
|
|
|
|
|
|
# Support for checking for suspicious markup
|
|
|
|
|
|
|
|
import suspicious
|
|
|
|
|
|
|
|
|
|
|
|
ISSUE_URI = 'https://bugs.python.org/issue%s'
|
2019-06-04 17:12:32 -03:00
|
|
|
SOURCE_URI = 'https://github.com/python/cpython/tree/master/%s'
|
2008-04-10 00:06:53 -03:00
|
|
|
|
Merged revisions 69129-69131,69139-69140,69143,69154-69159,69169,69288-69289,69293,69297-69301,69348 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r69129 | benjamin.peterson | 2009-01-30 19:42:55 -0600 (Fri, 30 Jan 2009) | 1 line
check the errno in bad fd cases
........
r69130 | andrew.kuchling | 2009-01-30 20:50:09 -0600 (Fri, 30 Jan 2009) | 1 line
Add a section
........
r69131 | andrew.kuchling | 2009-01-30 21:26:02 -0600 (Fri, 30 Jan 2009) | 1 line
Text edits and markup fixes
........
r69139 | mark.dickinson | 2009-01-31 10:44:04 -0600 (Sat, 31 Jan 2009) | 2 lines
Add an extra test for long <-> float hash equivalence.
........
r69140 | benjamin.peterson | 2009-01-31 10:52:03 -0600 (Sat, 31 Jan 2009) | 1 line
PyErr_BadInternalCall() raises a SystemError, not TypeError #5112
........
r69143 | benjamin.peterson | 2009-01-31 15:00:10 -0600 (Sat, 31 Jan 2009) | 1 line
I believe the intention here was to avoid a global lookup
........
r69154 | benjamin.peterson | 2009-01-31 16:33:02 -0600 (Sat, 31 Jan 2009) | 1 line
fix indentation in comment
........
r69155 | david.goodger | 2009-01-31 16:53:46 -0600 (Sat, 31 Jan 2009) | 1 line
markup fix
........
r69156 | gregory.p.smith | 2009-01-31 16:57:30 -0600 (Sat, 31 Jan 2009) | 4 lines
- Issue #5104: The socket module now raises OverflowError when 16-bit port and
protocol numbers are supplied outside the allowed 0-65536 range on bind()
and getservbyport().
........
r69157 | benjamin.peterson | 2009-01-31 17:43:25 -0600 (Sat, 31 Jan 2009) | 1 line
add explanatory comment
........
r69158 | benjamin.peterson | 2009-01-31 17:54:38 -0600 (Sat, 31 Jan 2009) | 1 line
more flags which only work for function blocks
........
r69159 | gregory.p.smith | 2009-01-31 18:16:01 -0600 (Sat, 31 Jan 2009) | 2 lines
Update doc wording as suggested in issue4903.
........
r69169 | guilherme.polo | 2009-01-31 20:56:16 -0600 (Sat, 31 Jan 2009) | 3 lines
Restore Tkinter.Tk._loadtk so this test doesn't fail for problems
related to ttk.
........
r69288 | georg.brandl | 2009-02-05 04:30:57 -0600 (Thu, 05 Feb 2009) | 1 line
#5153: fix typo in example.
........
r69289 | georg.brandl | 2009-02-05 04:37:07 -0600 (Thu, 05 Feb 2009) | 1 line
#5144: document that PySys_SetArgv prepends the script directory (or the empty string) to sys.path.
........
r69293 | georg.brandl | 2009-02-05 04:59:28 -0600 (Thu, 05 Feb 2009) | 1 line
#5059: fix example.
........
r69297 | georg.brandl | 2009-02-05 05:32:18 -0600 (Thu, 05 Feb 2009) | 1 line
#5015: document PythonHome API functions.
........
r69298 | georg.brandl | 2009-02-05 05:33:21 -0600 (Thu, 05 Feb 2009) | 1 line
#4827: fix callback example.
........
r69299 | georg.brandl | 2009-02-05 05:35:28 -0600 (Thu, 05 Feb 2009) | 1 line
#4820: use correct module for ctypes.util.
........
r69300 | georg.brandl | 2009-02-05 05:38:23 -0600 (Thu, 05 Feb 2009) | 1 line
#4563: disable alpha and roman lists, fixes wrong formatting of contributor list.
........
r69301 | georg.brandl | 2009-02-05 05:40:35 -0600 (Thu, 05 Feb 2009) | 1 line
#5031: fix Thread.daemon property docs.
........
r69348 | benjamin.peterson | 2009-02-05 19:47:31 -0600 (Thu, 05 Feb 2009) | 1 line
fix download link
........
2009-02-05 22:40:07 -04:00
|
|
|
# monkey-patch reST parser to disable alphabetic and roman enumerated lists
|
|
|
|
from docutils.parsers.rst.states import Body
|
|
|
|
Body.enum.converters['loweralpha'] = \
|
|
|
|
Body.enum.converters['upperalpha'] = \
|
|
|
|
Body.enum.converters['lowerroman'] = \
|
|
|
|
Body.enum.converters['upperroman'] = lambda x: None
|
|
|
|
|
2014-10-30 18:55:13 -03:00
|
|
|
|
Merged revisions 75365,75394,75402-75403,75418,75459,75484,75592-75596,75600,75602-75607,75610-75613,75616-75617,75623,75627,75640,75647,75696,75795 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r75365 | georg.brandl | 2009-10-11 22:16:16 +0200 (So, 11 Okt 2009) | 1 line
Fix broken links found by "make linkcheck". scipy.org seems to be done right now, so I could not verify links going there.
........
r75394 | georg.brandl | 2009-10-13 20:10:59 +0200 (Di, 13 Okt 2009) | 1 line
Fix markup.
........
r75402 | georg.brandl | 2009-10-14 17:51:48 +0200 (Mi, 14 Okt 2009) | 1 line
#7125: fix typo.
........
r75403 | georg.brandl | 2009-10-14 17:57:46 +0200 (Mi, 14 Okt 2009) | 1 line
#7126: os.environ changes *do* take effect in subprocesses started with os.system().
........
r75418 | georg.brandl | 2009-10-14 20:48:32 +0200 (Mi, 14 Okt 2009) | 1 line
#7116: str.join() takes an iterable.
........
r75459 | georg.brandl | 2009-10-17 10:57:43 +0200 (Sa, 17 Okt 2009) | 1 line
Fix refleaks in _ctypes PyCSimpleType_New, which fixes the refleak seen in test___all__.
........
r75484 | georg.brandl | 2009-10-18 09:58:12 +0200 (So, 18 Okt 2009) | 1 line
Fix missing word.
........
r75592 | georg.brandl | 2009-10-22 09:05:48 +0200 (Do, 22 Okt 2009) | 1 line
Fix punctuation.
........
r75593 | georg.brandl | 2009-10-22 09:06:49 +0200 (Do, 22 Okt 2009) | 1 line
Revert unintended change.
........
r75594 | georg.brandl | 2009-10-22 09:56:02 +0200 (Do, 22 Okt 2009) | 1 line
Fix markup.
........
r75595 | georg.brandl | 2009-10-22 09:56:56 +0200 (Do, 22 Okt 2009) | 1 line
Fix duplicate target.
........
r75596 | georg.brandl | 2009-10-22 10:05:04 +0200 (Do, 22 Okt 2009) | 1 line
Add a new directive marking up implementation details and start using it.
........
r75600 | georg.brandl | 2009-10-22 13:01:46 +0200 (Do, 22 Okt 2009) | 1 line
Make it more robust.
........
r75602 | georg.brandl | 2009-10-22 13:28:06 +0200 (Do, 22 Okt 2009) | 1 line
Document new directive.
........
r75603 | georg.brandl | 2009-10-22 13:28:23 +0200 (Do, 22 Okt 2009) | 1 line
Allow short form with text as argument.
........
r75604 | georg.brandl | 2009-10-22 13:36:50 +0200 (Do, 22 Okt 2009) | 1 line
Fix stylesheet for multi-paragraph impl-details.
........
r75605 | georg.brandl | 2009-10-22 13:48:10 +0200 (Do, 22 Okt 2009) | 1 line
Use "impl-detail" directive where applicable.
........
r75606 | georg.brandl | 2009-10-22 17:00:06 +0200 (Do, 22 Okt 2009) | 1 line
#6324: membership test tries iteration via __iter__.
........
r75607 | georg.brandl | 2009-10-22 17:04:09 +0200 (Do, 22 Okt 2009) | 1 line
#7088: document new functions in signal as Unix-only.
........
r75610 | georg.brandl | 2009-10-22 17:27:24 +0200 (Do, 22 Okt 2009) | 1 line
Reorder __slots__ fine print and add a clarification.
........
r75611 | georg.brandl | 2009-10-22 17:42:32 +0200 (Do, 22 Okt 2009) | 1 line
#7035: improve docs of the various <method>_errors() functions, and give them docstrings.
........
r75612 | georg.brandl | 2009-10-22 17:52:15 +0200 (Do, 22 Okt 2009) | 1 line
#7156: document curses as Unix-only.
........
r75613 | georg.brandl | 2009-10-22 17:54:35 +0200 (Do, 22 Okt 2009) | 1 line
#6977: getopt does not support optional option arguments.
........
r75616 | georg.brandl | 2009-10-22 18:17:05 +0200 (Do, 22 Okt 2009) | 1 line
Add proper references.
........
r75617 | georg.brandl | 2009-10-22 18:20:55 +0200 (Do, 22 Okt 2009) | 1 line
Make printout margin important.
........
r75623 | georg.brandl | 2009-10-23 10:14:44 +0200 (Fr, 23 Okt 2009) | 1 line
#7188: fix optionxform() docs.
........
r75627 | fred.drake | 2009-10-23 15:04:51 +0200 (Fr, 23 Okt 2009) | 2 lines
add further note about what's passed to optionxform
........
r75640 | neil.schemenauer | 2009-10-23 21:58:17 +0200 (Fr, 23 Okt 2009) | 2 lines
Improve some docstrings in the 'warnings' module.
........
r75647 | georg.brandl | 2009-10-24 12:04:19 +0200 (Sa, 24 Okt 2009) | 1 line
Fix markup.
........
r75696 | georg.brandl | 2009-10-25 21:25:43 +0100 (So, 25 Okt 2009) | 1 line
Fix a demo.
........
r75795 | georg.brandl | 2009-10-27 16:10:22 +0100 (Di, 27 Okt 2009) | 1 line
Fix a strange mis-edit.
........
2009-10-27 12:28:25 -03:00
|
|
|
# Support for marking up and linking to bugs.python.org issues
|
|
|
|
|
2008-04-10 00:06:53 -03:00
|
|
|
def issue_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
|
|
|
|
issue = utils.unescape(text)
|
2017-02-10 19:10:13 -04:00
|
|
|
text = 'bpo-' + issue
|
2008-04-10 00:06:53 -03:00
|
|
|
refnode = nodes.reference(text, text, refuri=ISSUE_URI % issue)
|
|
|
|
return [refnode], []
|
|
|
|
|
|
|
|
|
2010-11-06 04:19:35 -03:00
|
|
|
# Support for linking to Python source files easily
|
|
|
|
|
|
|
|
def source_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
|
|
|
|
has_t, title, target = split_explicit_title(text)
|
|
|
|
title = utils.unescape(title)
|
|
|
|
target = utils.unescape(target)
|
|
|
|
refnode = nodes.reference(title, title, refuri=SOURCE_URI % target)
|
|
|
|
return [refnode], []
|
|
|
|
|
|
|
|
|
Merged revisions 75365,75394,75402-75403,75418,75459,75484,75592-75596,75600,75602-75607,75610-75613,75616-75617,75623,75627,75640,75647,75696,75795 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r75365 | georg.brandl | 2009-10-11 22:16:16 +0200 (So, 11 Okt 2009) | 1 line
Fix broken links found by "make linkcheck". scipy.org seems to be done right now, so I could not verify links going there.
........
r75394 | georg.brandl | 2009-10-13 20:10:59 +0200 (Di, 13 Okt 2009) | 1 line
Fix markup.
........
r75402 | georg.brandl | 2009-10-14 17:51:48 +0200 (Mi, 14 Okt 2009) | 1 line
#7125: fix typo.
........
r75403 | georg.brandl | 2009-10-14 17:57:46 +0200 (Mi, 14 Okt 2009) | 1 line
#7126: os.environ changes *do* take effect in subprocesses started with os.system().
........
r75418 | georg.brandl | 2009-10-14 20:48:32 +0200 (Mi, 14 Okt 2009) | 1 line
#7116: str.join() takes an iterable.
........
r75459 | georg.brandl | 2009-10-17 10:57:43 +0200 (Sa, 17 Okt 2009) | 1 line
Fix refleaks in _ctypes PyCSimpleType_New, which fixes the refleak seen in test___all__.
........
r75484 | georg.brandl | 2009-10-18 09:58:12 +0200 (So, 18 Okt 2009) | 1 line
Fix missing word.
........
r75592 | georg.brandl | 2009-10-22 09:05:48 +0200 (Do, 22 Okt 2009) | 1 line
Fix punctuation.
........
r75593 | georg.brandl | 2009-10-22 09:06:49 +0200 (Do, 22 Okt 2009) | 1 line
Revert unintended change.
........
r75594 | georg.brandl | 2009-10-22 09:56:02 +0200 (Do, 22 Okt 2009) | 1 line
Fix markup.
........
r75595 | georg.brandl | 2009-10-22 09:56:56 +0200 (Do, 22 Okt 2009) | 1 line
Fix duplicate target.
........
r75596 | georg.brandl | 2009-10-22 10:05:04 +0200 (Do, 22 Okt 2009) | 1 line
Add a new directive marking up implementation details and start using it.
........
r75600 | georg.brandl | 2009-10-22 13:01:46 +0200 (Do, 22 Okt 2009) | 1 line
Make it more robust.
........
r75602 | georg.brandl | 2009-10-22 13:28:06 +0200 (Do, 22 Okt 2009) | 1 line
Document new directive.
........
r75603 | georg.brandl | 2009-10-22 13:28:23 +0200 (Do, 22 Okt 2009) | 1 line
Allow short form with text as argument.
........
r75604 | georg.brandl | 2009-10-22 13:36:50 +0200 (Do, 22 Okt 2009) | 1 line
Fix stylesheet for multi-paragraph impl-details.
........
r75605 | georg.brandl | 2009-10-22 13:48:10 +0200 (Do, 22 Okt 2009) | 1 line
Use "impl-detail" directive where applicable.
........
r75606 | georg.brandl | 2009-10-22 17:00:06 +0200 (Do, 22 Okt 2009) | 1 line
#6324: membership test tries iteration via __iter__.
........
r75607 | georg.brandl | 2009-10-22 17:04:09 +0200 (Do, 22 Okt 2009) | 1 line
#7088: document new functions in signal as Unix-only.
........
r75610 | georg.brandl | 2009-10-22 17:27:24 +0200 (Do, 22 Okt 2009) | 1 line
Reorder __slots__ fine print and add a clarification.
........
r75611 | georg.brandl | 2009-10-22 17:42:32 +0200 (Do, 22 Okt 2009) | 1 line
#7035: improve docs of the various <method>_errors() functions, and give them docstrings.
........
r75612 | georg.brandl | 2009-10-22 17:52:15 +0200 (Do, 22 Okt 2009) | 1 line
#7156: document curses as Unix-only.
........
r75613 | georg.brandl | 2009-10-22 17:54:35 +0200 (Do, 22 Okt 2009) | 1 line
#6977: getopt does not support optional option arguments.
........
r75616 | georg.brandl | 2009-10-22 18:17:05 +0200 (Do, 22 Okt 2009) | 1 line
Add proper references.
........
r75617 | georg.brandl | 2009-10-22 18:20:55 +0200 (Do, 22 Okt 2009) | 1 line
Make printout margin important.
........
r75623 | georg.brandl | 2009-10-23 10:14:44 +0200 (Fr, 23 Okt 2009) | 1 line
#7188: fix optionxform() docs.
........
r75627 | fred.drake | 2009-10-23 15:04:51 +0200 (Fr, 23 Okt 2009) | 2 lines
add further note about what's passed to optionxform
........
r75640 | neil.schemenauer | 2009-10-23 21:58:17 +0200 (Fr, 23 Okt 2009) | 2 lines
Improve some docstrings in the 'warnings' module.
........
r75647 | georg.brandl | 2009-10-24 12:04:19 +0200 (Sa, 24 Okt 2009) | 1 line
Fix markup.
........
r75696 | georg.brandl | 2009-10-25 21:25:43 +0100 (So, 25 Okt 2009) | 1 line
Fix a demo.
........
r75795 | georg.brandl | 2009-10-27 16:10:22 +0100 (Di, 27 Okt 2009) | 1 line
Fix a strange mis-edit.
........
2009-10-27 12:28:25 -03:00
|
|
|
# Support for marking up implementation details
|
|
|
|
|
|
|
|
class ImplementationDetail(Directive):
|
|
|
|
|
|
|
|
has_content = True
|
|
|
|
required_arguments = 0
|
|
|
|
optional_arguments = 1
|
|
|
|
final_argument_whitespace = True
|
|
|
|
|
2017-03-08 06:07:13 -04:00
|
|
|
# This text is copied to templates/dummy.html
|
|
|
|
label_text = 'CPython implementation detail:'
|
|
|
|
|
Merged revisions 75365,75394,75402-75403,75418,75459,75484,75592-75596,75600,75602-75607,75610-75613,75616-75617,75623,75627,75640,75647,75696,75795 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r75365 | georg.brandl | 2009-10-11 22:16:16 +0200 (So, 11 Okt 2009) | 1 line
Fix broken links found by "make linkcheck". scipy.org seems to be done right now, so I could not verify links going there.
........
r75394 | georg.brandl | 2009-10-13 20:10:59 +0200 (Di, 13 Okt 2009) | 1 line
Fix markup.
........
r75402 | georg.brandl | 2009-10-14 17:51:48 +0200 (Mi, 14 Okt 2009) | 1 line
#7125: fix typo.
........
r75403 | georg.brandl | 2009-10-14 17:57:46 +0200 (Mi, 14 Okt 2009) | 1 line
#7126: os.environ changes *do* take effect in subprocesses started with os.system().
........
r75418 | georg.brandl | 2009-10-14 20:48:32 +0200 (Mi, 14 Okt 2009) | 1 line
#7116: str.join() takes an iterable.
........
r75459 | georg.brandl | 2009-10-17 10:57:43 +0200 (Sa, 17 Okt 2009) | 1 line
Fix refleaks in _ctypes PyCSimpleType_New, which fixes the refleak seen in test___all__.
........
r75484 | georg.brandl | 2009-10-18 09:58:12 +0200 (So, 18 Okt 2009) | 1 line
Fix missing word.
........
r75592 | georg.brandl | 2009-10-22 09:05:48 +0200 (Do, 22 Okt 2009) | 1 line
Fix punctuation.
........
r75593 | georg.brandl | 2009-10-22 09:06:49 +0200 (Do, 22 Okt 2009) | 1 line
Revert unintended change.
........
r75594 | georg.brandl | 2009-10-22 09:56:02 +0200 (Do, 22 Okt 2009) | 1 line
Fix markup.
........
r75595 | georg.brandl | 2009-10-22 09:56:56 +0200 (Do, 22 Okt 2009) | 1 line
Fix duplicate target.
........
r75596 | georg.brandl | 2009-10-22 10:05:04 +0200 (Do, 22 Okt 2009) | 1 line
Add a new directive marking up implementation details and start using it.
........
r75600 | georg.brandl | 2009-10-22 13:01:46 +0200 (Do, 22 Okt 2009) | 1 line
Make it more robust.
........
r75602 | georg.brandl | 2009-10-22 13:28:06 +0200 (Do, 22 Okt 2009) | 1 line
Document new directive.
........
r75603 | georg.brandl | 2009-10-22 13:28:23 +0200 (Do, 22 Okt 2009) | 1 line
Allow short form with text as argument.
........
r75604 | georg.brandl | 2009-10-22 13:36:50 +0200 (Do, 22 Okt 2009) | 1 line
Fix stylesheet for multi-paragraph impl-details.
........
r75605 | georg.brandl | 2009-10-22 13:48:10 +0200 (Do, 22 Okt 2009) | 1 line
Use "impl-detail" directive where applicable.
........
r75606 | georg.brandl | 2009-10-22 17:00:06 +0200 (Do, 22 Okt 2009) | 1 line
#6324: membership test tries iteration via __iter__.
........
r75607 | georg.brandl | 2009-10-22 17:04:09 +0200 (Do, 22 Okt 2009) | 1 line
#7088: document new functions in signal as Unix-only.
........
r75610 | georg.brandl | 2009-10-22 17:27:24 +0200 (Do, 22 Okt 2009) | 1 line
Reorder __slots__ fine print and add a clarification.
........
r75611 | georg.brandl | 2009-10-22 17:42:32 +0200 (Do, 22 Okt 2009) | 1 line
#7035: improve docs of the various <method>_errors() functions, and give them docstrings.
........
r75612 | georg.brandl | 2009-10-22 17:52:15 +0200 (Do, 22 Okt 2009) | 1 line
#7156: document curses as Unix-only.
........
r75613 | georg.brandl | 2009-10-22 17:54:35 +0200 (Do, 22 Okt 2009) | 1 line
#6977: getopt does not support optional option arguments.
........
r75616 | georg.brandl | 2009-10-22 18:17:05 +0200 (Do, 22 Okt 2009) | 1 line
Add proper references.
........
r75617 | georg.brandl | 2009-10-22 18:20:55 +0200 (Do, 22 Okt 2009) | 1 line
Make printout margin important.
........
r75623 | georg.brandl | 2009-10-23 10:14:44 +0200 (Fr, 23 Okt 2009) | 1 line
#7188: fix optionxform() docs.
........
r75627 | fred.drake | 2009-10-23 15:04:51 +0200 (Fr, 23 Okt 2009) | 2 lines
add further note about what's passed to optionxform
........
r75640 | neil.schemenauer | 2009-10-23 21:58:17 +0200 (Fr, 23 Okt 2009) | 2 lines
Improve some docstrings in the 'warnings' module.
........
r75647 | georg.brandl | 2009-10-24 12:04:19 +0200 (Sa, 24 Okt 2009) | 1 line
Fix markup.
........
r75696 | georg.brandl | 2009-10-25 21:25:43 +0100 (So, 25 Okt 2009) | 1 line
Fix a demo.
........
r75795 | georg.brandl | 2009-10-27 16:10:22 +0100 (Di, 27 Okt 2009) | 1 line
Fix a strange mis-edit.
........
2009-10-27 12:28:25 -03:00
|
|
|
def run(self):
|
|
|
|
pnode = nodes.compound(classes=['impl-detail'])
|
2017-03-08 06:07:13 -04:00
|
|
|
label = translators['sphinx'].gettext(self.label_text)
|
Merged revisions 75365,75394,75402-75403,75418,75459,75484,75592-75596,75600,75602-75607,75610-75613,75616-75617,75623,75627,75640,75647,75696,75795 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r75365 | georg.brandl | 2009-10-11 22:16:16 +0200 (So, 11 Okt 2009) | 1 line
Fix broken links found by "make linkcheck". scipy.org seems to be done right now, so I could not verify links going there.
........
r75394 | georg.brandl | 2009-10-13 20:10:59 +0200 (Di, 13 Okt 2009) | 1 line
Fix markup.
........
r75402 | georg.brandl | 2009-10-14 17:51:48 +0200 (Mi, 14 Okt 2009) | 1 line
#7125: fix typo.
........
r75403 | georg.brandl | 2009-10-14 17:57:46 +0200 (Mi, 14 Okt 2009) | 1 line
#7126: os.environ changes *do* take effect in subprocesses started with os.system().
........
r75418 | georg.brandl | 2009-10-14 20:48:32 +0200 (Mi, 14 Okt 2009) | 1 line
#7116: str.join() takes an iterable.
........
r75459 | georg.brandl | 2009-10-17 10:57:43 +0200 (Sa, 17 Okt 2009) | 1 line
Fix refleaks in _ctypes PyCSimpleType_New, which fixes the refleak seen in test___all__.
........
r75484 | georg.brandl | 2009-10-18 09:58:12 +0200 (So, 18 Okt 2009) | 1 line
Fix missing word.
........
r75592 | georg.brandl | 2009-10-22 09:05:48 +0200 (Do, 22 Okt 2009) | 1 line
Fix punctuation.
........
r75593 | georg.brandl | 2009-10-22 09:06:49 +0200 (Do, 22 Okt 2009) | 1 line
Revert unintended change.
........
r75594 | georg.brandl | 2009-10-22 09:56:02 +0200 (Do, 22 Okt 2009) | 1 line
Fix markup.
........
r75595 | georg.brandl | 2009-10-22 09:56:56 +0200 (Do, 22 Okt 2009) | 1 line
Fix duplicate target.
........
r75596 | georg.brandl | 2009-10-22 10:05:04 +0200 (Do, 22 Okt 2009) | 1 line
Add a new directive marking up implementation details and start using it.
........
r75600 | georg.brandl | 2009-10-22 13:01:46 +0200 (Do, 22 Okt 2009) | 1 line
Make it more robust.
........
r75602 | georg.brandl | 2009-10-22 13:28:06 +0200 (Do, 22 Okt 2009) | 1 line
Document new directive.
........
r75603 | georg.brandl | 2009-10-22 13:28:23 +0200 (Do, 22 Okt 2009) | 1 line
Allow short form with text as argument.
........
r75604 | georg.brandl | 2009-10-22 13:36:50 +0200 (Do, 22 Okt 2009) | 1 line
Fix stylesheet for multi-paragraph impl-details.
........
r75605 | georg.brandl | 2009-10-22 13:48:10 +0200 (Do, 22 Okt 2009) | 1 line
Use "impl-detail" directive where applicable.
........
r75606 | georg.brandl | 2009-10-22 17:00:06 +0200 (Do, 22 Okt 2009) | 1 line
#6324: membership test tries iteration via __iter__.
........
r75607 | georg.brandl | 2009-10-22 17:04:09 +0200 (Do, 22 Okt 2009) | 1 line
#7088: document new functions in signal as Unix-only.
........
r75610 | georg.brandl | 2009-10-22 17:27:24 +0200 (Do, 22 Okt 2009) | 1 line
Reorder __slots__ fine print and add a clarification.
........
r75611 | georg.brandl | 2009-10-22 17:42:32 +0200 (Do, 22 Okt 2009) | 1 line
#7035: improve docs of the various <method>_errors() functions, and give them docstrings.
........
r75612 | georg.brandl | 2009-10-22 17:52:15 +0200 (Do, 22 Okt 2009) | 1 line
#7156: document curses as Unix-only.
........
r75613 | georg.brandl | 2009-10-22 17:54:35 +0200 (Do, 22 Okt 2009) | 1 line
#6977: getopt does not support optional option arguments.
........
r75616 | georg.brandl | 2009-10-22 18:17:05 +0200 (Do, 22 Okt 2009) | 1 line
Add proper references.
........
r75617 | georg.brandl | 2009-10-22 18:20:55 +0200 (Do, 22 Okt 2009) | 1 line
Make printout margin important.
........
r75623 | georg.brandl | 2009-10-23 10:14:44 +0200 (Fr, 23 Okt 2009) | 1 line
#7188: fix optionxform() docs.
........
r75627 | fred.drake | 2009-10-23 15:04:51 +0200 (Fr, 23 Okt 2009) | 2 lines
add further note about what's passed to optionxform
........
r75640 | neil.schemenauer | 2009-10-23 21:58:17 +0200 (Fr, 23 Okt 2009) | 2 lines
Improve some docstrings in the 'warnings' module.
........
r75647 | georg.brandl | 2009-10-24 12:04:19 +0200 (Sa, 24 Okt 2009) | 1 line
Fix markup.
........
r75696 | georg.brandl | 2009-10-25 21:25:43 +0100 (So, 25 Okt 2009) | 1 line
Fix a demo.
........
r75795 | georg.brandl | 2009-10-27 16:10:22 +0100 (Di, 27 Okt 2009) | 1 line
Fix a strange mis-edit.
........
2009-10-27 12:28:25 -03:00
|
|
|
content = self.content
|
2017-03-08 06:07:13 -04:00
|
|
|
add_text = nodes.strong(label, label)
|
Merged revisions 75365,75394,75402-75403,75418,75459,75484,75592-75596,75600,75602-75607,75610-75613,75616-75617,75623,75627,75640,75647,75696,75795 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r75365 | georg.brandl | 2009-10-11 22:16:16 +0200 (So, 11 Okt 2009) | 1 line
Fix broken links found by "make linkcheck". scipy.org seems to be done right now, so I could not verify links going there.
........
r75394 | georg.brandl | 2009-10-13 20:10:59 +0200 (Di, 13 Okt 2009) | 1 line
Fix markup.
........
r75402 | georg.brandl | 2009-10-14 17:51:48 +0200 (Mi, 14 Okt 2009) | 1 line
#7125: fix typo.
........
r75403 | georg.brandl | 2009-10-14 17:57:46 +0200 (Mi, 14 Okt 2009) | 1 line
#7126: os.environ changes *do* take effect in subprocesses started with os.system().
........
r75418 | georg.brandl | 2009-10-14 20:48:32 +0200 (Mi, 14 Okt 2009) | 1 line
#7116: str.join() takes an iterable.
........
r75459 | georg.brandl | 2009-10-17 10:57:43 +0200 (Sa, 17 Okt 2009) | 1 line
Fix refleaks in _ctypes PyCSimpleType_New, which fixes the refleak seen in test___all__.
........
r75484 | georg.brandl | 2009-10-18 09:58:12 +0200 (So, 18 Okt 2009) | 1 line
Fix missing word.
........
r75592 | georg.brandl | 2009-10-22 09:05:48 +0200 (Do, 22 Okt 2009) | 1 line
Fix punctuation.
........
r75593 | georg.brandl | 2009-10-22 09:06:49 +0200 (Do, 22 Okt 2009) | 1 line
Revert unintended change.
........
r75594 | georg.brandl | 2009-10-22 09:56:02 +0200 (Do, 22 Okt 2009) | 1 line
Fix markup.
........
r75595 | georg.brandl | 2009-10-22 09:56:56 +0200 (Do, 22 Okt 2009) | 1 line
Fix duplicate target.
........
r75596 | georg.brandl | 2009-10-22 10:05:04 +0200 (Do, 22 Okt 2009) | 1 line
Add a new directive marking up implementation details and start using it.
........
r75600 | georg.brandl | 2009-10-22 13:01:46 +0200 (Do, 22 Okt 2009) | 1 line
Make it more robust.
........
r75602 | georg.brandl | 2009-10-22 13:28:06 +0200 (Do, 22 Okt 2009) | 1 line
Document new directive.
........
r75603 | georg.brandl | 2009-10-22 13:28:23 +0200 (Do, 22 Okt 2009) | 1 line
Allow short form with text as argument.
........
r75604 | georg.brandl | 2009-10-22 13:36:50 +0200 (Do, 22 Okt 2009) | 1 line
Fix stylesheet for multi-paragraph impl-details.
........
r75605 | georg.brandl | 2009-10-22 13:48:10 +0200 (Do, 22 Okt 2009) | 1 line
Use "impl-detail" directive where applicable.
........
r75606 | georg.brandl | 2009-10-22 17:00:06 +0200 (Do, 22 Okt 2009) | 1 line
#6324: membership test tries iteration via __iter__.
........
r75607 | georg.brandl | 2009-10-22 17:04:09 +0200 (Do, 22 Okt 2009) | 1 line
#7088: document new functions in signal as Unix-only.
........
r75610 | georg.brandl | 2009-10-22 17:27:24 +0200 (Do, 22 Okt 2009) | 1 line
Reorder __slots__ fine print and add a clarification.
........
r75611 | georg.brandl | 2009-10-22 17:42:32 +0200 (Do, 22 Okt 2009) | 1 line
#7035: improve docs of the various <method>_errors() functions, and give them docstrings.
........
r75612 | georg.brandl | 2009-10-22 17:52:15 +0200 (Do, 22 Okt 2009) | 1 line
#7156: document curses as Unix-only.
........
r75613 | georg.brandl | 2009-10-22 17:54:35 +0200 (Do, 22 Okt 2009) | 1 line
#6977: getopt does not support optional option arguments.
........
r75616 | georg.brandl | 2009-10-22 18:17:05 +0200 (Do, 22 Okt 2009) | 1 line
Add proper references.
........
r75617 | georg.brandl | 2009-10-22 18:20:55 +0200 (Do, 22 Okt 2009) | 1 line
Make printout margin important.
........
r75623 | georg.brandl | 2009-10-23 10:14:44 +0200 (Fr, 23 Okt 2009) | 1 line
#7188: fix optionxform() docs.
........
r75627 | fred.drake | 2009-10-23 15:04:51 +0200 (Fr, 23 Okt 2009) | 2 lines
add further note about what's passed to optionxform
........
r75640 | neil.schemenauer | 2009-10-23 21:58:17 +0200 (Fr, 23 Okt 2009) | 2 lines
Improve some docstrings in the 'warnings' module.
........
r75647 | georg.brandl | 2009-10-24 12:04:19 +0200 (Sa, 24 Okt 2009) | 1 line
Fix markup.
........
r75696 | georg.brandl | 2009-10-25 21:25:43 +0100 (So, 25 Okt 2009) | 1 line
Fix a demo.
........
r75795 | georg.brandl | 2009-10-27 16:10:22 +0100 (Di, 27 Okt 2009) | 1 line
Fix a strange mis-edit.
........
2009-10-27 12:28:25 -03:00
|
|
|
if self.arguments:
|
|
|
|
n, m = self.state.inline_text(self.arguments[0], self.lineno)
|
|
|
|
pnode.append(nodes.paragraph('', '', *(n + m)))
|
|
|
|
self.state.nested_parse(content, self.content_offset, pnode)
|
|
|
|
if pnode.children and isinstance(pnode[0], nodes.paragraph):
|
2017-03-08 06:07:13 -04:00
|
|
|
content = nodes.inline(pnode[0].rawsource, translatable=True)
|
|
|
|
content.source = pnode[0].source
|
|
|
|
content.line = pnode[0].line
|
|
|
|
content += pnode[0].children
|
|
|
|
pnode[0].replace_self(nodes.paragraph('', '', content,
|
|
|
|
translatable=False))
|
Merged revisions 75365,75394,75402-75403,75418,75459,75484,75592-75596,75600,75602-75607,75610-75613,75616-75617,75623,75627,75640,75647,75696,75795 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r75365 | georg.brandl | 2009-10-11 22:16:16 +0200 (So, 11 Okt 2009) | 1 line
Fix broken links found by "make linkcheck". scipy.org seems to be done right now, so I could not verify links going there.
........
r75394 | georg.brandl | 2009-10-13 20:10:59 +0200 (Di, 13 Okt 2009) | 1 line
Fix markup.
........
r75402 | georg.brandl | 2009-10-14 17:51:48 +0200 (Mi, 14 Okt 2009) | 1 line
#7125: fix typo.
........
r75403 | georg.brandl | 2009-10-14 17:57:46 +0200 (Mi, 14 Okt 2009) | 1 line
#7126: os.environ changes *do* take effect in subprocesses started with os.system().
........
r75418 | georg.brandl | 2009-10-14 20:48:32 +0200 (Mi, 14 Okt 2009) | 1 line
#7116: str.join() takes an iterable.
........
r75459 | georg.brandl | 2009-10-17 10:57:43 +0200 (Sa, 17 Okt 2009) | 1 line
Fix refleaks in _ctypes PyCSimpleType_New, which fixes the refleak seen in test___all__.
........
r75484 | georg.brandl | 2009-10-18 09:58:12 +0200 (So, 18 Okt 2009) | 1 line
Fix missing word.
........
r75592 | georg.brandl | 2009-10-22 09:05:48 +0200 (Do, 22 Okt 2009) | 1 line
Fix punctuation.
........
r75593 | georg.brandl | 2009-10-22 09:06:49 +0200 (Do, 22 Okt 2009) | 1 line
Revert unintended change.
........
r75594 | georg.brandl | 2009-10-22 09:56:02 +0200 (Do, 22 Okt 2009) | 1 line
Fix markup.
........
r75595 | georg.brandl | 2009-10-22 09:56:56 +0200 (Do, 22 Okt 2009) | 1 line
Fix duplicate target.
........
r75596 | georg.brandl | 2009-10-22 10:05:04 +0200 (Do, 22 Okt 2009) | 1 line
Add a new directive marking up implementation details and start using it.
........
r75600 | georg.brandl | 2009-10-22 13:01:46 +0200 (Do, 22 Okt 2009) | 1 line
Make it more robust.
........
r75602 | georg.brandl | 2009-10-22 13:28:06 +0200 (Do, 22 Okt 2009) | 1 line
Document new directive.
........
r75603 | georg.brandl | 2009-10-22 13:28:23 +0200 (Do, 22 Okt 2009) | 1 line
Allow short form with text as argument.
........
r75604 | georg.brandl | 2009-10-22 13:36:50 +0200 (Do, 22 Okt 2009) | 1 line
Fix stylesheet for multi-paragraph impl-details.
........
r75605 | georg.brandl | 2009-10-22 13:48:10 +0200 (Do, 22 Okt 2009) | 1 line
Use "impl-detail" directive where applicable.
........
r75606 | georg.brandl | 2009-10-22 17:00:06 +0200 (Do, 22 Okt 2009) | 1 line
#6324: membership test tries iteration via __iter__.
........
r75607 | georg.brandl | 2009-10-22 17:04:09 +0200 (Do, 22 Okt 2009) | 1 line
#7088: document new functions in signal as Unix-only.
........
r75610 | georg.brandl | 2009-10-22 17:27:24 +0200 (Do, 22 Okt 2009) | 1 line
Reorder __slots__ fine print and add a clarification.
........
r75611 | georg.brandl | 2009-10-22 17:42:32 +0200 (Do, 22 Okt 2009) | 1 line
#7035: improve docs of the various <method>_errors() functions, and give them docstrings.
........
r75612 | georg.brandl | 2009-10-22 17:52:15 +0200 (Do, 22 Okt 2009) | 1 line
#7156: document curses as Unix-only.
........
r75613 | georg.brandl | 2009-10-22 17:54:35 +0200 (Do, 22 Okt 2009) | 1 line
#6977: getopt does not support optional option arguments.
........
r75616 | georg.brandl | 2009-10-22 18:17:05 +0200 (Do, 22 Okt 2009) | 1 line
Add proper references.
........
r75617 | georg.brandl | 2009-10-22 18:20:55 +0200 (Do, 22 Okt 2009) | 1 line
Make printout margin important.
........
r75623 | georg.brandl | 2009-10-23 10:14:44 +0200 (Fr, 23 Okt 2009) | 1 line
#7188: fix optionxform() docs.
........
r75627 | fred.drake | 2009-10-23 15:04:51 +0200 (Fr, 23 Okt 2009) | 2 lines
add further note about what's passed to optionxform
........
r75640 | neil.schemenauer | 2009-10-23 21:58:17 +0200 (Fr, 23 Okt 2009) | 2 lines
Improve some docstrings in the 'warnings' module.
........
r75647 | georg.brandl | 2009-10-24 12:04:19 +0200 (Sa, 24 Okt 2009) | 1 line
Fix markup.
........
r75696 | georg.brandl | 2009-10-25 21:25:43 +0100 (So, 25 Okt 2009) | 1 line
Fix a demo.
........
r75795 | georg.brandl | 2009-10-27 16:10:22 +0100 (Di, 27 Okt 2009) | 1 line
Fix a strange mis-edit.
........
2009-10-27 12:28:25 -03:00
|
|
|
pnode[0].insert(0, add_text)
|
|
|
|
pnode[0].insert(1, nodes.Text(' '))
|
|
|
|
else:
|
|
|
|
pnode.insert(0, nodes.paragraph('', '', add_text))
|
|
|
|
return [pnode]
|
|
|
|
|
|
|
|
|
2018-10-12 11:55:20 -03:00
|
|
|
# Support for documenting platform availability
|
|
|
|
|
|
|
|
class Availability(Directive):
|
|
|
|
|
|
|
|
has_content = False
|
|
|
|
required_arguments = 1
|
|
|
|
optional_arguments = 0
|
|
|
|
final_argument_whitespace = True
|
|
|
|
|
|
|
|
def run(self):
|
2018-11-07 17:42:40 -04:00
|
|
|
availability_ref = ':ref:`Availability <availability>`: '
|
|
|
|
pnode = nodes.paragraph(availability_ref + self.arguments[0],
|
|
|
|
classes=["availability"],)
|
|
|
|
n, m = self.state.inline_text(availability_ref, self.lineno)
|
2018-10-12 11:55:20 -03:00
|
|
|
pnode.extend(n + m)
|
|
|
|
n, m = self.state.inline_text(self.arguments[0], self.lineno)
|
|
|
|
pnode.extend(n + m)
|
|
|
|
return [pnode]
|
|
|
|
|
|
|
|
|
2019-05-23 12:45:22 -03:00
|
|
|
# Support for documenting audit event
|
|
|
|
|
2020-07-06 17:28:15 -03:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2019-05-23 12:45:22 -03:00
|
|
|
class AuditEvent(Directive):
|
|
|
|
|
|
|
|
has_content = True
|
|
|
|
required_arguments = 1
|
2019-06-27 14:47:59 -03:00
|
|
|
optional_arguments = 2
|
2019-05-23 12:45:22 -03:00
|
|
|
final_argument_whitespace = True
|
|
|
|
|
|
|
|
_label = [
|
|
|
|
"Raises an :ref:`auditing event <auditing>` {name} with no arguments.",
|
|
|
|
"Raises an :ref:`auditing event <auditing>` {name} with argument {args}.",
|
|
|
|
"Raises an :ref:`auditing event <auditing>` {name} with arguments {args}.",
|
|
|
|
]
|
|
|
|
|
2019-06-27 14:47:59 -03:00
|
|
|
@property
|
|
|
|
def logger(self):
|
|
|
|
cls = type(self)
|
|
|
|
return logging.getLogger(cls.__module__ + "." + cls.__name__)
|
|
|
|
|
2019-05-23 12:45:22 -03:00
|
|
|
def run(self):
|
2019-06-27 14:47:59 -03:00
|
|
|
name = self.arguments[0]
|
2019-05-23 12:45:22 -03:00
|
|
|
if len(self.arguments) >= 2 and self.arguments[1]:
|
2019-06-27 14:47:59 -03:00
|
|
|
args = (a.strip() for a in self.arguments[1].strip("'\"").split(","))
|
|
|
|
args = [a for a in args if a]
|
2019-05-23 12:45:22 -03:00
|
|
|
else:
|
|
|
|
args = []
|
|
|
|
|
|
|
|
label = translators['sphinx'].gettext(self._label[min(2, len(args))])
|
2019-06-27 14:47:59 -03:00
|
|
|
text = label.format(name="``{}``".format(name),
|
|
|
|
args=", ".join("``{}``".format(a) for a in args if a))
|
|
|
|
|
|
|
|
env = self.state.document.settings.env
|
|
|
|
if not hasattr(env, 'all_audit_events'):
|
|
|
|
env.all_audit_events = {}
|
|
|
|
|
|
|
|
new_info = {
|
|
|
|
'source': [],
|
|
|
|
'args': args
|
|
|
|
}
|
|
|
|
info = env.all_audit_events.setdefault(name, new_info)
|
|
|
|
if info is not new_info:
|
|
|
|
if not self._do_args_match(info['args'], new_info['args']):
|
|
|
|
self.logger.warn(
|
|
|
|
"Mismatched arguments for audit-event {}: {!r} != {!r}"
|
|
|
|
.format(name, info['args'], new_info['args'])
|
|
|
|
)
|
|
|
|
|
2019-07-01 20:03:53 -03:00
|
|
|
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)
|
|
|
|
|
2019-06-27 14:47:59 -03:00
|
|
|
info['source'].append((env.docname, target))
|
2019-05-23 12:45:22 -03:00
|
|
|
|
2019-06-27 14:47:59 -03:00
|
|
|
pnode = nodes.paragraph(text, classes=["audit-hook"], ids=ids)
|
2019-05-23 12:45:22 -03:00
|
|
|
if self.content:
|
|
|
|
self.state.nested_parse(self.content, self.content_offset, pnode)
|
|
|
|
else:
|
|
|
|
n, m = self.state.inline_text(text, self.lineno)
|
|
|
|
pnode.extend(n + m)
|
|
|
|
|
|
|
|
return [pnode]
|
|
|
|
|
2019-06-27 14:47:59 -03:00
|
|
|
# This list of sets are allowable synonyms for event argument names.
|
|
|
|
# If two names are in the same set, they are treated as equal for the
|
|
|
|
# purposes of warning. This won't help if number of arguments is
|
|
|
|
# different!
|
|
|
|
_SYNONYMS = [
|
|
|
|
{"file", "path", "fd"},
|
|
|
|
]
|
|
|
|
|
|
|
|
def _do_args_match(self, args1, args2):
|
|
|
|
if args1 == args2:
|
|
|
|
return True
|
|
|
|
if len(args1) != len(args2):
|
|
|
|
return False
|
|
|
|
for a1, a2 in zip(args1, args2):
|
|
|
|
if a1 == a2:
|
|
|
|
continue
|
|
|
|
if any(a1 in s and a2 in s for s in self._SYNONYMS):
|
|
|
|
continue
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
class audit_event_list(nodes.General, nodes.Element):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class AuditEventListDirective(Directive):
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
return [audit_event_list('')]
|
|
|
|
|
2019-05-23 12:45:22 -03:00
|
|
|
|
2010-07-29 13:01:11 -03:00
|
|
|
# Support for documenting decorators
|
|
|
|
|
|
|
|
class PyDecoratorMixin(object):
|
|
|
|
def handle_signature(self, sig, signode):
|
|
|
|
ret = super(PyDecoratorMixin, self).handle_signature(sig, signode)
|
|
|
|
signode.insert(0, addnodes.desc_addname('@', '@'))
|
|
|
|
return ret
|
|
|
|
|
|
|
|
def needs_arglist(self):
|
|
|
|
return False
|
|
|
|
|
2014-10-30 18:55:13 -03:00
|
|
|
|
2020-09-18 06:22:36 -03:00
|
|
|
class PyDecoratorFunction(PyDecoratorMixin, PyFunction):
|
2010-07-29 13:01:11 -03:00
|
|
|
def run(self):
|
|
|
|
# a decorator function is a function after all
|
|
|
|
self.name = 'py:function'
|
2020-09-18 06:22:36 -03:00
|
|
|
return PyFunction.run(self)
|
2010-07-29 13:01:11 -03:00
|
|
|
|
2014-10-30 18:55:13 -03:00
|
|
|
|
2020-09-18 06:22:36 -03:00
|
|
|
# TODO: Use sphinx.domains.python.PyDecoratorMethod when possible
|
|
|
|
class PyDecoratorMethod(PyDecoratorMixin, PyMethod):
|
2010-07-29 13:01:11 -03:00
|
|
|
def run(self):
|
|
|
|
self.name = 'py:method'
|
2020-09-18 06:22:36 -03:00
|
|
|
return PyMethod.run(self)
|
2010-07-29 13:01:11 -03:00
|
|
|
|
|
|
|
|
2015-02-12 17:49:18 -04:00
|
|
|
class PyCoroutineMixin(object):
|
|
|
|
def handle_signature(self, sig, signode):
|
|
|
|
ret = super(PyCoroutineMixin, self).handle_signature(sig, signode)
|
|
|
|
signode.insert(0, addnodes.desc_annotation('coroutine ', 'coroutine '))
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
2018-09-18 18:55:44 -03:00
|
|
|
class PyAwaitableMixin(object):
|
|
|
|
def handle_signature(self, sig, signode):
|
|
|
|
ret = super(PyAwaitableMixin, self).handle_signature(sig, signode)
|
|
|
|
signode.insert(0, addnodes.desc_annotation('awaitable ', 'awaitable '))
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
2020-09-18 06:22:36 -03:00
|
|
|
class PyCoroutineFunction(PyCoroutineMixin, PyFunction):
|
2015-02-12 17:49:18 -04:00
|
|
|
def run(self):
|
|
|
|
self.name = 'py:function'
|
2020-09-18 06:22:36 -03:00
|
|
|
return PyFunction.run(self)
|
2015-02-12 17:49:18 -04:00
|
|
|
|
|
|
|
|
2020-09-18 06:22:36 -03:00
|
|
|
class PyCoroutineMethod(PyCoroutineMixin, PyMethod):
|
2015-02-12 17:49:18 -04:00
|
|
|
def run(self):
|
|
|
|
self.name = 'py:method'
|
2020-09-18 06:22:36 -03:00
|
|
|
return PyMethod.run(self)
|
2015-02-12 17:49:18 -04:00
|
|
|
|
|
|
|
|
2020-09-18 06:22:36 -03:00
|
|
|
class PyAwaitableFunction(PyAwaitableMixin, PyFunction):
|
2018-09-18 18:55:44 -03:00
|
|
|
def run(self):
|
|
|
|
self.name = 'py:function'
|
2020-09-18 06:22:36 -03:00
|
|
|
return PyFunction.run(self)
|
2018-09-18 18:55:44 -03:00
|
|
|
|
|
|
|
|
2020-09-18 06:22:36 -03:00
|
|
|
class PyAwaitableMethod(PyAwaitableMixin, PyMethod):
|
2018-09-18 18:55:44 -03:00
|
|
|
def run(self):
|
|
|
|
self.name = 'py:method'
|
2020-09-18 06:22:36 -03:00
|
|
|
return PyMethod.run(self)
|
2018-09-18 18:55:44 -03:00
|
|
|
|
|
|
|
|
2020-09-18 06:22:36 -03:00
|
|
|
class PyAbstractMethod(PyMethod):
|
2015-12-08 06:14:50 -04:00
|
|
|
|
|
|
|
def handle_signature(self, sig, signode):
|
|
|
|
ret = super(PyAbstractMethod, self).handle_signature(sig, signode)
|
|
|
|
signode.insert(0, addnodes.desc_annotation('abstractmethod ',
|
|
|
|
'abstractmethod '))
|
|
|
|
return ret
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
self.name = 'py:method'
|
2020-09-18 06:22:36 -03:00
|
|
|
return PyMethod.run(self)
|
2015-12-08 06:14:50 -04:00
|
|
|
|
|
|
|
|
2010-11-12 04:57:12 -04:00
|
|
|
# Support for documenting version of removal in deprecations
|
|
|
|
|
|
|
|
class DeprecatedRemoved(Directive):
|
|
|
|
has_content = True
|
|
|
|
required_arguments = 2
|
|
|
|
optional_arguments = 1
|
|
|
|
final_argument_whitespace = True
|
|
|
|
option_spec = {}
|
|
|
|
|
2020-05-30 04:47:32 -03:00
|
|
|
_deprecated_label = 'Deprecated since version {deprecated}, will be removed in version {removed}'
|
|
|
|
_removed_label = 'Deprecated since version {deprecated}, removed in version {removed}'
|
2014-01-21 14:20:31 -04:00
|
|
|
|
2010-11-12 04:57:12 -04:00
|
|
|
def run(self):
|
|
|
|
node = addnodes.versionmodified()
|
|
|
|
node.document = self.state.document
|
|
|
|
node['type'] = 'deprecated-removed'
|
|
|
|
version = (self.arguments[0], self.arguments[1])
|
|
|
|
node['version'] = version
|
2020-05-30 04:47:32 -03:00
|
|
|
env = self.state.document.settings.env
|
|
|
|
current_version = tuple(int(e) for e in env.config.version.split('.'))
|
|
|
|
removed_version = tuple(int(e) for e in self.arguments[1].split('.'))
|
|
|
|
if current_version < removed_version:
|
|
|
|
label = self._deprecated_label
|
|
|
|
else:
|
|
|
|
label = self._removed_label
|
|
|
|
|
|
|
|
label = translators['sphinx'].gettext(label)
|
2018-02-23 07:47:19 -04:00
|
|
|
text = label.format(deprecated=self.arguments[0], removed=self.arguments[1])
|
2010-11-12 04:57:12 -04:00
|
|
|
if len(self.arguments) == 3:
|
|
|
|
inodes, messages = self.state.inline_text(self.arguments[2],
|
|
|
|
self.lineno+1)
|
2018-02-23 07:47:19 -04:00
|
|
|
para = nodes.paragraph(self.arguments[2], '', *inodes, translatable=False)
|
2014-01-21 14:20:31 -04:00
|
|
|
node.append(para)
|
|
|
|
else:
|
|
|
|
messages = []
|
|
|
|
if self.content:
|
|
|
|
self.state.nested_parse(self.content, self.content_offset, node)
|
2014-11-08 16:40:22 -04:00
|
|
|
if len(node):
|
2014-01-21 14:20:31 -04:00
|
|
|
if isinstance(node[0], nodes.paragraph) and node[0].rawsource:
|
|
|
|
content = nodes.inline(node[0].rawsource, translatable=True)
|
|
|
|
content.source = node[0].source
|
|
|
|
content.line = node[0].line
|
|
|
|
content += node[0].children
|
2018-02-23 07:47:19 -04:00
|
|
|
node[0].replace_self(nodes.paragraph('', '', content, translatable=False))
|
2014-11-08 16:40:22 -04:00
|
|
|
node[0].insert(0, nodes.inline('', '%s: ' % text,
|
|
|
|
classes=['versionmodified']))
|
2014-09-22 18:44:22 -03:00
|
|
|
else:
|
2014-01-21 14:20:31 -04:00
|
|
|
para = nodes.paragraph('', '',
|
2014-10-30 18:55:13 -03:00
|
|
|
nodes.inline('', '%s.' % text,
|
2018-02-23 07:47:19 -04:00
|
|
|
classes=['versionmodified']),
|
|
|
|
translatable=False)
|
2014-11-08 16:40:22 -04:00
|
|
|
node.append(para)
|
2010-11-12 04:57:12 -04:00
|
|
|
env = self.state.document.settings.env
|
2019-05-10 18:58:17 -03:00
|
|
|
env.get_domain('changeset').note_changeset(node)
|
2014-01-21 14:20:31 -04:00
|
|
|
return [node] + messages
|
2010-11-12 04:57:12 -04:00
|
|
|
|
|
|
|
|
2012-09-30 10:10:06 -03:00
|
|
|
# Support for including Misc/NEWS
|
|
|
|
|
2017-02-10 19:10:13 -04:00
|
|
|
issue_re = re.compile('(?:[Ii]ssue #|bpo-)([0-9]+)')
|
2012-10-01 14:08:50 -03:00
|
|
|
whatsnew_re = re.compile(r"(?im)^what's new in (.*?)\??$")
|
2012-09-30 10:10:06 -03:00
|
|
|
|
2014-10-30 18:55:13 -03:00
|
|
|
|
2012-09-30 10:10:06 -03:00
|
|
|
class MiscNews(Directive):
|
|
|
|
has_content = False
|
|
|
|
required_arguments = 1
|
|
|
|
optional_arguments = 0
|
|
|
|
final_argument_whitespace = False
|
|
|
|
option_spec = {}
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
fname = self.arguments[0]
|
|
|
|
source = self.state_machine.input_lines.source(
|
|
|
|
self.lineno - self.state_machine.input_offset - 1)
|
2018-12-19 22:20:06 -04:00
|
|
|
source_dir = getenv('PY_MISC_NEWS_DIR')
|
|
|
|
if not source_dir:
|
|
|
|
source_dir = path.dirname(path.abspath(source))
|
2012-10-01 14:08:50 -03:00
|
|
|
fpath = path.join(source_dir, fname)
|
|
|
|
self.state.document.settings.record_dependencies.add(fpath)
|
2012-09-30 10:10:06 -03:00
|
|
|
try:
|
2017-06-16 03:59:01 -03:00
|
|
|
with io.open(fpath, encoding='utf-8') as fp:
|
2012-09-30 10:10:06 -03:00
|
|
|
content = fp.read()
|
|
|
|
except Exception:
|
|
|
|
text = 'The NEWS file is not available.'
|
|
|
|
node = nodes.strong(text, text)
|
|
|
|
return [node]
|
2017-02-10 19:10:13 -04:00
|
|
|
content = issue_re.sub(r'`bpo-\1 <https://bugs.python.org/issue\1>`__',
|
2012-09-30 10:10:06 -03:00
|
|
|
content)
|
2012-10-01 14:08:50 -03:00
|
|
|
content = whatsnew_re.sub(r'\1', content)
|
2012-09-30 10:10:06 -03:00
|
|
|
# remove first 3 lines as they are the main heading
|
2012-10-01 14:27:05 -03:00
|
|
|
lines = ['.. default-role:: obj', ''] + content.splitlines()[3:]
|
2012-09-30 10:10:06 -03:00
|
|
|
self.state_machine.insert_input(lines, fname)
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
2008-06-01 18:05:17 -03:00
|
|
|
# Support for building "topic help" for pydoc
|
|
|
|
|
|
|
|
pydoc_topic_labels = [
|
2017-10-06 00:24:46 -03:00
|
|
|
'assert', 'assignment', 'async', 'atom-identifiers', 'atom-literals',
|
|
|
|
'attribute-access', 'attribute-references', 'augassign', 'await',
|
|
|
|
'binary', 'bitwise', 'bltin-code-objects', 'bltin-ellipsis-object',
|
2010-06-05 23:44:41 -03:00
|
|
|
'bltin-null-object', 'bltin-type-objects', 'booleans',
|
2008-06-01 18:05:17 -03:00
|
|
|
'break', 'callable-types', 'calls', 'class', 'comparisons', 'compound',
|
|
|
|
'context-managers', 'continue', 'conversions', 'customization', 'debugger',
|
|
|
|
'del', 'dict', 'dynamic-features', 'else', 'exceptions', 'execmodel',
|
|
|
|
'exprlists', 'floating', 'for', 'formatstrings', 'function', 'global',
|
|
|
|
'id-classes', 'identifiers', 'if', 'imaginary', 'import', 'in', 'integers',
|
2010-08-31 11:31:01 -03:00
|
|
|
'lambda', 'lists', 'naming', 'nonlocal', 'numbers', 'numeric-types',
|
|
|
|
'objects', 'operator-summary', 'pass', 'power', 'raise', 'return',
|
|
|
|
'sequence-types', 'shifting', 'slicings', 'specialattrs', 'specialnames',
|
|
|
|
'string-methods', 'strings', 'subscriptions', 'truth', 'try', 'types',
|
|
|
|
'typesfunctions', 'typesmapping', 'typesmethods', 'typesmodules',
|
|
|
|
'typesseq', 'typesseq-mutable', 'unary', 'while', 'with', 'yield'
|
2008-06-01 18:05:17 -03:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
class PydocTopicsBuilder(Builder):
|
|
|
|
name = 'pydoc-topics'
|
|
|
|
|
2018-04-17 02:56:46 -03:00
|
|
|
default_translator_class = TextTranslator
|
|
|
|
|
2008-06-01 18:05:17 -03:00
|
|
|
def init(self):
|
|
|
|
self.topics = {}
|
2018-04-17 02:56:46 -03:00
|
|
|
self.secnumbers = {}
|
2008-06-01 18:05:17 -03:00
|
|
|
|
|
|
|
def get_outdated_docs(self):
|
|
|
|
return 'all pydoc topics'
|
|
|
|
|
|
|
|
def get_target_uri(self, docname, typ=None):
|
|
|
|
return '' # no URIs
|
|
|
|
|
|
|
|
def write(self, *ignored):
|
|
|
|
writer = TextWriter(self)
|
2018-04-17 02:56:46 -03:00
|
|
|
for label in status_iterator(pydoc_topic_labels,
|
|
|
|
'building topics... ',
|
|
|
|
length=len(pydoc_topic_labels)):
|
2010-07-31 05:27:46 -03:00
|
|
|
if label not in self.env.domaindata['std']['labels']:
|
2019-06-27 14:47:59 -03:00
|
|
|
self.env.logger.warn('label %r not in documentation' % label)
|
2008-06-01 18:05:17 -03:00
|
|
|
continue
|
2010-07-31 05:27:46 -03:00
|
|
|
docname, labelid, sectname = self.env.domaindata['std']['labels'][label]
|
2008-06-01 18:05:17 -03:00
|
|
|
doctree = self.env.get_and_resolve_doctree(docname, self)
|
|
|
|
document = new_document('<section node>')
|
|
|
|
document.append(doctree.ids[labelid])
|
|
|
|
destination = StringOutput(encoding='utf-8')
|
|
|
|
writer.write(document, destination)
|
2014-09-22 18:44:22 -03:00
|
|
|
self.topics[label] = writer.output
|
2008-06-01 18:05:17 -03:00
|
|
|
|
|
|
|
def finish(self):
|
2014-09-22 18:44:22 -03:00
|
|
|
f = open(path.join(self.outdir, 'topics.py'), 'wb')
|
2008-06-01 18:05:17 -03:00
|
|
|
try:
|
2014-09-22 18:44:22 -03:00
|
|
|
f.write('# -*- coding: utf-8 -*-\n'.encode('utf-8'))
|
|
|
|
f.write(('# Autogenerated by Sphinx on %s\n' % asctime()).encode('utf-8'))
|
|
|
|
f.write(('topics = ' + pformat(self.topics) + '\n').encode('utf-8'))
|
2008-06-01 18:05:17 -03:00
|
|
|
finally:
|
|
|
|
f.close()
|
|
|
|
|
Merged revisions 75365,75394,75402-75403,75418,75459,75484,75592-75596,75600,75602-75607,75610-75613,75616-75617,75623,75627,75640,75647,75696,75795 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r75365 | georg.brandl | 2009-10-11 22:16:16 +0200 (So, 11 Okt 2009) | 1 line
Fix broken links found by "make linkcheck". scipy.org seems to be done right now, so I could not verify links going there.
........
r75394 | georg.brandl | 2009-10-13 20:10:59 +0200 (Di, 13 Okt 2009) | 1 line
Fix markup.
........
r75402 | georg.brandl | 2009-10-14 17:51:48 +0200 (Mi, 14 Okt 2009) | 1 line
#7125: fix typo.
........
r75403 | georg.brandl | 2009-10-14 17:57:46 +0200 (Mi, 14 Okt 2009) | 1 line
#7126: os.environ changes *do* take effect in subprocesses started with os.system().
........
r75418 | georg.brandl | 2009-10-14 20:48:32 +0200 (Mi, 14 Okt 2009) | 1 line
#7116: str.join() takes an iterable.
........
r75459 | georg.brandl | 2009-10-17 10:57:43 +0200 (Sa, 17 Okt 2009) | 1 line
Fix refleaks in _ctypes PyCSimpleType_New, which fixes the refleak seen in test___all__.
........
r75484 | georg.brandl | 2009-10-18 09:58:12 +0200 (So, 18 Okt 2009) | 1 line
Fix missing word.
........
r75592 | georg.brandl | 2009-10-22 09:05:48 +0200 (Do, 22 Okt 2009) | 1 line
Fix punctuation.
........
r75593 | georg.brandl | 2009-10-22 09:06:49 +0200 (Do, 22 Okt 2009) | 1 line
Revert unintended change.
........
r75594 | georg.brandl | 2009-10-22 09:56:02 +0200 (Do, 22 Okt 2009) | 1 line
Fix markup.
........
r75595 | georg.brandl | 2009-10-22 09:56:56 +0200 (Do, 22 Okt 2009) | 1 line
Fix duplicate target.
........
r75596 | georg.brandl | 2009-10-22 10:05:04 +0200 (Do, 22 Okt 2009) | 1 line
Add a new directive marking up implementation details and start using it.
........
r75600 | georg.brandl | 2009-10-22 13:01:46 +0200 (Do, 22 Okt 2009) | 1 line
Make it more robust.
........
r75602 | georg.brandl | 2009-10-22 13:28:06 +0200 (Do, 22 Okt 2009) | 1 line
Document new directive.
........
r75603 | georg.brandl | 2009-10-22 13:28:23 +0200 (Do, 22 Okt 2009) | 1 line
Allow short form with text as argument.
........
r75604 | georg.brandl | 2009-10-22 13:36:50 +0200 (Do, 22 Okt 2009) | 1 line
Fix stylesheet for multi-paragraph impl-details.
........
r75605 | georg.brandl | 2009-10-22 13:48:10 +0200 (Do, 22 Okt 2009) | 1 line
Use "impl-detail" directive where applicable.
........
r75606 | georg.brandl | 2009-10-22 17:00:06 +0200 (Do, 22 Okt 2009) | 1 line
#6324: membership test tries iteration via __iter__.
........
r75607 | georg.brandl | 2009-10-22 17:04:09 +0200 (Do, 22 Okt 2009) | 1 line
#7088: document new functions in signal as Unix-only.
........
r75610 | georg.brandl | 2009-10-22 17:27:24 +0200 (Do, 22 Okt 2009) | 1 line
Reorder __slots__ fine print and add a clarification.
........
r75611 | georg.brandl | 2009-10-22 17:42:32 +0200 (Do, 22 Okt 2009) | 1 line
#7035: improve docs of the various <method>_errors() functions, and give them docstrings.
........
r75612 | georg.brandl | 2009-10-22 17:52:15 +0200 (Do, 22 Okt 2009) | 1 line
#7156: document curses as Unix-only.
........
r75613 | georg.brandl | 2009-10-22 17:54:35 +0200 (Do, 22 Okt 2009) | 1 line
#6977: getopt does not support optional option arguments.
........
r75616 | georg.brandl | 2009-10-22 18:17:05 +0200 (Do, 22 Okt 2009) | 1 line
Add proper references.
........
r75617 | georg.brandl | 2009-10-22 18:20:55 +0200 (Do, 22 Okt 2009) | 1 line
Make printout margin important.
........
r75623 | georg.brandl | 2009-10-23 10:14:44 +0200 (Fr, 23 Okt 2009) | 1 line
#7188: fix optionxform() docs.
........
r75627 | fred.drake | 2009-10-23 15:04:51 +0200 (Fr, 23 Okt 2009) | 2 lines
add further note about what's passed to optionxform
........
r75640 | neil.schemenauer | 2009-10-23 21:58:17 +0200 (Fr, 23 Okt 2009) | 2 lines
Improve some docstrings in the 'warnings' module.
........
r75647 | georg.brandl | 2009-10-24 12:04:19 +0200 (Sa, 24 Okt 2009) | 1 line
Fix markup.
........
r75696 | georg.brandl | 2009-10-25 21:25:43 +0100 (So, 25 Okt 2009) | 1 line
Fix a demo.
........
r75795 | georg.brandl | 2009-10-27 16:10:22 +0100 (Di, 27 Okt 2009) | 1 line
Fix a strange mis-edit.
........
2009-10-27 12:28:25 -03:00
|
|
|
|
2008-07-23 12:19:11 -03:00
|
|
|
# Support for documenting Opcodes
|
|
|
|
|
2010-07-03 07:41:33 -03:00
|
|
|
opcode_sig_re = re.compile(r'(\w+(?:\+\d)?)(?:\s*\((.*)\))?')
|
2008-07-23 12:19:11 -03:00
|
|
|
|
2014-10-30 18:55:13 -03:00
|
|
|
|
2008-07-23 12:19:11 -03:00
|
|
|
def parse_opcode_signature(env, sig, signode):
|
|
|
|
"""Transform an opcode signature into RST nodes."""
|
|
|
|
m = opcode_sig_re.match(sig)
|
|
|
|
if m is None:
|
|
|
|
raise ValueError
|
|
|
|
opname, arglist = m.groups()
|
|
|
|
signode += addnodes.desc_name(opname, opname)
|
2010-07-03 07:41:33 -03:00
|
|
|
if arglist is not None:
|
|
|
|
paramlist = addnodes.desc_parameterlist()
|
|
|
|
signode += paramlist
|
|
|
|
paramlist += addnodes.desc_parameter(arglist, arglist)
|
2008-07-23 12:19:11 -03:00
|
|
|
return opname.strip()
|
|
|
|
|
|
|
|
|
2010-11-12 04:57:12 -04:00
|
|
|
# Support for documenting pdb commands
|
|
|
|
|
2010-07-18 07:11:03 -03:00
|
|
|
pdbcmd_sig_re = re.compile(r'([a-z()!]+)\s*(.*)')
|
|
|
|
|
|
|
|
# later...
|
2014-10-30 18:55:13 -03:00
|
|
|
# pdbargs_tokens_re = re.compile(r'''[a-zA-Z]+ | # identifiers
|
2010-07-18 07:11:03 -03:00
|
|
|
# [.,:]+ | # punctuation
|
|
|
|
# [\[\]()] | # parens
|
|
|
|
# \s+ # whitespace
|
|
|
|
# ''', re.X)
|
|
|
|
|
2014-10-30 18:55:13 -03:00
|
|
|
|
2010-07-18 07:11:03 -03:00
|
|
|
def parse_pdb_command(env, sig, signode):
|
|
|
|
"""Transform a pdb command signature into RST nodes."""
|
|
|
|
m = pdbcmd_sig_re.match(sig)
|
|
|
|
if m is None:
|
|
|
|
raise ValueError
|
|
|
|
name, args = m.groups()
|
|
|
|
fullname = name.replace('(', '').replace(')', '')
|
|
|
|
signode += addnodes.desc_name(name, name)
|
|
|
|
if args:
|
|
|
|
signode += addnodes.desc_addname(' '+args, ' '+args)
|
|
|
|
return fullname
|
|
|
|
|
|
|
|
|
2019-06-27 14:47:59 -03:00
|
|
|
def process_audit_events(app, doctree, fromdocname):
|
|
|
|
for node in doctree.traverse(audit_event_list):
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
return
|
|
|
|
|
|
|
|
env = app.builder.env
|
|
|
|
|
|
|
|
table = nodes.table(cols=3)
|
|
|
|
group = nodes.tgroup(
|
|
|
|
'',
|
|
|
|
nodes.colspec(colwidth=30),
|
|
|
|
nodes.colspec(colwidth=55),
|
|
|
|
nodes.colspec(colwidth=15),
|
2019-09-10 11:40:50 -03:00
|
|
|
cols=3,
|
2019-06-27 14:47:59 -03:00
|
|
|
)
|
|
|
|
head = nodes.thead()
|
|
|
|
body = nodes.tbody()
|
|
|
|
|
|
|
|
table += group
|
|
|
|
group += head
|
|
|
|
group += body
|
|
|
|
|
|
|
|
row = nodes.row()
|
|
|
|
row += nodes.entry('', nodes.paragraph('', nodes.Text('Audit event')))
|
|
|
|
row += nodes.entry('', nodes.paragraph('', nodes.Text('Arguments')))
|
|
|
|
row += nodes.entry('', nodes.paragraph('', nodes.Text('References')))
|
|
|
|
head += row
|
|
|
|
|
|
|
|
for name in sorted(getattr(env, "all_audit_events", ())):
|
|
|
|
audit_event = env.all_audit_events[name]
|
|
|
|
|
|
|
|
row = nodes.row()
|
|
|
|
node = nodes.paragraph('', nodes.Text(name))
|
|
|
|
row += nodes.entry('', node)
|
|
|
|
|
|
|
|
node = nodes.paragraph()
|
|
|
|
for i, a in enumerate(audit_event['args']):
|
|
|
|
if i:
|
|
|
|
node += nodes.Text(", ")
|
|
|
|
node += nodes.literal(a, nodes.Text(a))
|
|
|
|
row += nodes.entry('', node)
|
|
|
|
|
|
|
|
node = nodes.paragraph()
|
2019-07-01 20:03:53 -03:00
|
|
|
backlinks = enumerate(sorted(set(audit_event['source'])), start=1)
|
|
|
|
for i, (doc, label) in backlinks:
|
2019-06-27 14:47:59 -03:00
|
|
|
if isinstance(label, str):
|
|
|
|
ref = nodes.reference("", nodes.Text("[{}]".format(i)), internal=True)
|
2019-09-09 07:54:56 -03:00
|
|
|
try:
|
|
|
|
ref['refuri'] = "{}#{}".format(
|
|
|
|
app.builder.get_relative_uri(fromdocname, doc),
|
|
|
|
label,
|
|
|
|
)
|
|
|
|
except NoUri:
|
|
|
|
continue
|
2019-06-27 14:47:59 -03:00
|
|
|
node += ref
|
|
|
|
row += nodes.entry('', node)
|
|
|
|
|
|
|
|
body += row
|
|
|
|
|
|
|
|
for node in doctree.traverse(audit_event_list):
|
|
|
|
node.replace_self(table)
|
|
|
|
|
|
|
|
|
2008-04-10 00:06:53 -03:00
|
|
|
def setup(app):
|
|
|
|
app.add_role('issue', issue_role)
|
2010-11-06 04:19:35 -03:00
|
|
|
app.add_role('source', source_role)
|
Merged revisions 75365,75394,75402-75403,75418,75459,75484,75592-75596,75600,75602-75607,75610-75613,75616-75617,75623,75627,75640,75647,75696,75795 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r75365 | georg.brandl | 2009-10-11 22:16:16 +0200 (So, 11 Okt 2009) | 1 line
Fix broken links found by "make linkcheck". scipy.org seems to be done right now, so I could not verify links going there.
........
r75394 | georg.brandl | 2009-10-13 20:10:59 +0200 (Di, 13 Okt 2009) | 1 line
Fix markup.
........
r75402 | georg.brandl | 2009-10-14 17:51:48 +0200 (Mi, 14 Okt 2009) | 1 line
#7125: fix typo.
........
r75403 | georg.brandl | 2009-10-14 17:57:46 +0200 (Mi, 14 Okt 2009) | 1 line
#7126: os.environ changes *do* take effect in subprocesses started with os.system().
........
r75418 | georg.brandl | 2009-10-14 20:48:32 +0200 (Mi, 14 Okt 2009) | 1 line
#7116: str.join() takes an iterable.
........
r75459 | georg.brandl | 2009-10-17 10:57:43 +0200 (Sa, 17 Okt 2009) | 1 line
Fix refleaks in _ctypes PyCSimpleType_New, which fixes the refleak seen in test___all__.
........
r75484 | georg.brandl | 2009-10-18 09:58:12 +0200 (So, 18 Okt 2009) | 1 line
Fix missing word.
........
r75592 | georg.brandl | 2009-10-22 09:05:48 +0200 (Do, 22 Okt 2009) | 1 line
Fix punctuation.
........
r75593 | georg.brandl | 2009-10-22 09:06:49 +0200 (Do, 22 Okt 2009) | 1 line
Revert unintended change.
........
r75594 | georg.brandl | 2009-10-22 09:56:02 +0200 (Do, 22 Okt 2009) | 1 line
Fix markup.
........
r75595 | georg.brandl | 2009-10-22 09:56:56 +0200 (Do, 22 Okt 2009) | 1 line
Fix duplicate target.
........
r75596 | georg.brandl | 2009-10-22 10:05:04 +0200 (Do, 22 Okt 2009) | 1 line
Add a new directive marking up implementation details and start using it.
........
r75600 | georg.brandl | 2009-10-22 13:01:46 +0200 (Do, 22 Okt 2009) | 1 line
Make it more robust.
........
r75602 | georg.brandl | 2009-10-22 13:28:06 +0200 (Do, 22 Okt 2009) | 1 line
Document new directive.
........
r75603 | georg.brandl | 2009-10-22 13:28:23 +0200 (Do, 22 Okt 2009) | 1 line
Allow short form with text as argument.
........
r75604 | georg.brandl | 2009-10-22 13:36:50 +0200 (Do, 22 Okt 2009) | 1 line
Fix stylesheet for multi-paragraph impl-details.
........
r75605 | georg.brandl | 2009-10-22 13:48:10 +0200 (Do, 22 Okt 2009) | 1 line
Use "impl-detail" directive where applicable.
........
r75606 | georg.brandl | 2009-10-22 17:00:06 +0200 (Do, 22 Okt 2009) | 1 line
#6324: membership test tries iteration via __iter__.
........
r75607 | georg.brandl | 2009-10-22 17:04:09 +0200 (Do, 22 Okt 2009) | 1 line
#7088: document new functions in signal as Unix-only.
........
r75610 | georg.brandl | 2009-10-22 17:27:24 +0200 (Do, 22 Okt 2009) | 1 line
Reorder __slots__ fine print and add a clarification.
........
r75611 | georg.brandl | 2009-10-22 17:42:32 +0200 (Do, 22 Okt 2009) | 1 line
#7035: improve docs of the various <method>_errors() functions, and give them docstrings.
........
r75612 | georg.brandl | 2009-10-22 17:52:15 +0200 (Do, 22 Okt 2009) | 1 line
#7156: document curses as Unix-only.
........
r75613 | georg.brandl | 2009-10-22 17:54:35 +0200 (Do, 22 Okt 2009) | 1 line
#6977: getopt does not support optional option arguments.
........
r75616 | georg.brandl | 2009-10-22 18:17:05 +0200 (Do, 22 Okt 2009) | 1 line
Add proper references.
........
r75617 | georg.brandl | 2009-10-22 18:20:55 +0200 (Do, 22 Okt 2009) | 1 line
Make printout margin important.
........
r75623 | georg.brandl | 2009-10-23 10:14:44 +0200 (Fr, 23 Okt 2009) | 1 line
#7188: fix optionxform() docs.
........
r75627 | fred.drake | 2009-10-23 15:04:51 +0200 (Fr, 23 Okt 2009) | 2 lines
add further note about what's passed to optionxform
........
r75640 | neil.schemenauer | 2009-10-23 21:58:17 +0200 (Fr, 23 Okt 2009) | 2 lines
Improve some docstrings in the 'warnings' module.
........
r75647 | georg.brandl | 2009-10-24 12:04:19 +0200 (Sa, 24 Okt 2009) | 1 line
Fix markup.
........
r75696 | georg.brandl | 2009-10-25 21:25:43 +0100 (So, 25 Okt 2009) | 1 line
Fix a demo.
........
r75795 | georg.brandl | 2009-10-27 16:10:22 +0100 (Di, 27 Okt 2009) | 1 line
Fix a strange mis-edit.
........
2009-10-27 12:28:25 -03:00
|
|
|
app.add_directive('impl-detail', ImplementationDetail)
|
2018-10-12 11:55:20 -03:00
|
|
|
app.add_directive('availability', Availability)
|
2019-05-23 12:45:22 -03:00
|
|
|
app.add_directive('audit-event', AuditEvent)
|
2019-06-27 14:47:59 -03:00
|
|
|
app.add_directive('audit-event-table', AuditEventListDirective)
|
2010-11-12 04:57:12 -04:00
|
|
|
app.add_directive('deprecated-removed', DeprecatedRemoved)
|
2008-06-01 18:05:17 -03:00
|
|
|
app.add_builder(PydocTopicsBuilder)
|
Merged revisions 68288-68291,68325-68326,68338,68388,68393,68423 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
................
r68288 | benjamin.peterson | 2009-01-03 18:39:07 -0600 (Sat, 03 Jan 2009) | 1 line
only check the actual compile() call for a SyntaxError
................
r68289 | georg.brandl | 2009-01-04 02:26:10 -0600 (Sun, 04 Jan 2009) | 2 lines
Test commit.
................
r68290 | georg.brandl | 2009-01-04 04:23:49 -0600 (Sun, 04 Jan 2009) | 4 lines
Add "suspicious" builder which finds leftover markup in the HTML files.
Patch by Gabriel Genellina.
................
r68291 | georg.brandl | 2009-01-04 04:24:09 -0600 (Sun, 04 Jan 2009) | 2 lines
Fix two issues found by the suspicious builder.
................
r68325 | benjamin.peterson | 2009-01-04 16:00:18 -0600 (Sun, 04 Jan 2009) | 1 line
use Jinja 2.1.1
................
r68326 | georg.brandl | 2009-01-04 16:03:10 -0600 (Sun, 04 Jan 2009) | 2 lines
Update make.bat.
................
r68338 | neal.norwitz | 2009-01-04 21:57:25 -0600 (Sun, 04 Jan 2009) | 1 line
Make sure to checkout any new packages
................
r68388 | benjamin.peterson | 2009-01-07 21:39:46 -0600 (Wed, 07 Jan 2009) | 1 line
string exceptions are gone
................
r68393 | benjamin.peterson | 2009-01-07 22:01:00 -0600 (Wed, 07 Jan 2009) | 1 line
use new sphinx modules
................
r68423 | benjamin.peterson | 2009-01-08 20:13:34 -0600 (Thu, 08 Jan 2009) | 29 lines
Merged revisions 68306-68308,68340,68368,68422 via svnmerge from
svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
........
r68306 | benjamin.peterson | 2009-01-04 12:27:19 -0600 (Sun, 04 Jan 2009) | 1 line
fix_urllib: add mappings for the url parsing functions
........
r68307 | benjamin.peterson | 2009-01-04 12:30:01 -0600 (Sun, 04 Jan 2009) | 1 line
remove duplicated function
........
r68308 | benjamin.peterson | 2009-01-04 12:50:34 -0600 (Sun, 04 Jan 2009) | 1 line
turtle is no longer renamed
........
r68340 | georg.brandl | 2009-01-05 02:11:39 -0600 (Mon, 05 Jan 2009) | 2 lines
Fix undefined locals in parse_tokens().
........
r68368 | benjamin.peterson | 2009-01-06 17:56:10 -0600 (Tue, 06 Jan 2009) | 1 line
fix typo (thanks to Robert Lehmann)
........
r68422 | benjamin.peterson | 2009-01-08 20:01:03 -0600 (Thu, 08 Jan 2009) | 1 line
run the imports fixers after fix_import, so fix_import doesn't try to make stdlib renames into relative imports #4876
........
................
2009-01-08 23:03:23 -04:00
|
|
|
app.add_builder(suspicious.CheckSuspiciousMarkupBuilder)
|
2018-10-13 03:14:08 -03:00
|
|
|
app.add_object_type('opcode', 'opcode', '%s (opcode)', parse_opcode_signature)
|
|
|
|
app.add_object_type('pdbcommand', 'pdbcmd', '%s (pdb command)', parse_pdb_command)
|
|
|
|
app.add_object_type('2to3fixer', '2to3fixer', '%s (2to3 fixer)')
|
2010-07-29 13:01:11 -03:00
|
|
|
app.add_directive_to_domain('py', 'decorator', PyDecoratorFunction)
|
|
|
|
app.add_directive_to_domain('py', 'decoratormethod', PyDecoratorMethod)
|
2015-02-12 17:49:18 -04:00
|
|
|
app.add_directive_to_domain('py', 'coroutinefunction', PyCoroutineFunction)
|
|
|
|
app.add_directive_to_domain('py', 'coroutinemethod', PyCoroutineMethod)
|
2018-09-18 18:55:44 -03:00
|
|
|
app.add_directive_to_domain('py', 'awaitablefunction', PyAwaitableFunction)
|
|
|
|
app.add_directive_to_domain('py', 'awaitablemethod', PyAwaitableMethod)
|
2015-12-08 06:14:50 -04:00
|
|
|
app.add_directive_to_domain('py', 'abstractmethod', PyAbstractMethod)
|
2012-09-30 10:10:06 -03:00
|
|
|
app.add_directive('miscnews', MiscNews)
|
2019-06-27 14:47:59 -03:00
|
|
|
app.connect('doctree-resolved', process_audit_events)
|
2020-07-06 17:28:15 -03:00
|
|
|
app.connect('env-merge-info', audit_events_merge)
|
|
|
|
app.connect('env-purge-doc', audit_events_purge)
|
2014-09-30 17:17:41 -03:00
|
|
|
return {'version': '1.0', 'parallel_read_safe': True}
|