diff options
Diffstat (limited to 'Doc/tools')
-rwxr-xr-x | Doc/tools/rstlint.py | 2 | ||||
-rw-r--r-- | Doc/tools/sphinxext/download.html | 4 | ||||
-rw-r--r-- | Doc/tools/sphinxext/indexcontent.html | 2 | ||||
-rw-r--r-- | Doc/tools/sphinxext/indexsidebar.html | 2 | ||||
-rw-r--r-- | Doc/tools/sphinxext/patchlevel.py | 2 | ||||
-rw-r--r-- | Doc/tools/sphinxext/pyspecific.py | 108 | ||||
-rw-r--r-- | Doc/tools/sphinxext/static/basic.css | 10 | ||||
-rw-r--r-- | Doc/tools/sphinxext/susp-ignored.csv | 252 | ||||
-rw-r--r-- | Doc/tools/sphinxext/suspicious.py | 52 |
9 files changed, 318 insertions, 116 deletions
diff --git a/Doc/tools/rstlint.py b/Doc/tools/rstlint.py index e977f21..2cc3d12 100755 --- a/Doc/tools/rstlint.py +++ b/Doc/tools/rstlint.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Check for stylistic and formal issues in .rst and .py diff --git a/Doc/tools/sphinxext/download.html b/Doc/tools/sphinxext/download.html index 4fca138..f89c458 100644 --- a/Doc/tools/sphinxext/download.html +++ b/Doc/tools/sphinxext/download.html @@ -33,6 +33,10 @@ in the table are the size of the download files in megabytes.</p> <td><a href="{{ dlbase }}/python-{{ release }}-docs-text.zip">Download</a> (ca. 2 MB)</td> <td><a href="{{ dlbase }}/python-{{ release }}-docs-text.tar.bz2">Download</a> (ca. 1.5 MB)</td> </tr> + <tr><td>EPUB</td> + <td><a href="{{ dlbase }}/python-{{ release }}-docs-epub.zip">Download</a> (ca. 3.5 MB)</td> + <td><a href="{{ dlbase }}/python-{{ release }}-docs-epub.tar.bz2">Download</a> (ca. 3.5 MB)</td> + </tr> </table> diff --git a/Doc/tools/sphinxext/indexcontent.html b/Doc/tools/sphinxext/indexcontent.html index 30963c3..d5e17cd 100644 --- a/Doc/tools/sphinxext/indexcontent.html +++ b/Doc/tools/sphinxext/indexcontent.html @@ -34,7 +34,7 @@ <p><strong>Indices and tables:</strong></p> <table class="contentstable" align="center"><tr> <td width="50%"> - <p class="biglink"><a class="biglink" href="{{ pathto("modindex") }}">Global Module Index</a><br/> + <p class="biglink"><a class="biglink" href="{{ pathto("py-modindex") }}">Global Module Index</a><br/> <span class="linkdescr">quick access to all modules</span></p> <p class="biglink"><a class="biglink" href="{{ pathto("genindex") }}">General Index</a><br/> <span class="linkdescr">all functions, classes, terms</span></p> diff --git a/Doc/tools/sphinxext/indexsidebar.html b/Doc/tools/sphinxext/indexsidebar.html index 086d883..672492e 100644 --- a/Doc/tools/sphinxext/indexsidebar.html +++ b/Doc/tools/sphinxext/indexsidebar.html @@ -3,7 +3,7 @@ <h3>Docs for other versions</h3> <ul> <li><a href="http://docs.python.org/2.7/">Python 2.7 (stable)</a></li> - <li><a href="http://docs.python.org/dev/py3k/">Python 3.2 (in development)</a></li> + <li><a href="http://docs.python.org/3.1/">Python 3.1 (stable)</a></li> <li><a href="http://www.python.org/doc/versions/">Old versions</a></li> </ul> diff --git a/Doc/tools/sphinxext/patchlevel.py b/Doc/tools/sphinxext/patchlevel.py index 082858e..b070d60 100644 --- a/Doc/tools/sphinxext/patchlevel.py +++ b/Doc/tools/sphinxext/patchlevel.py @@ -68,4 +68,4 @@ def get_version_info(): return version, release if __name__ == '__main__': - print get_header_version_info('.')[1] + print(get_header_version_info('.')[1]) diff --git a/Doc/tools/sphinxext/pyspecific.py b/Doc/tools/sphinxext/pyspecific.py index 7111c06..d928cfd 100644 --- a/Doc/tools/sphinxext/pyspecific.py +++ b/Doc/tools/sphinxext/pyspecific.py @@ -10,8 +10,10 @@ """ ISSUE_URI = 'http://bugs.python.org/issue%s' +SOURCE_URI = 'http://hg.python.org/cpython/file/default/%s' from docutils import nodes, utils +from sphinx.util.nodes import split_explicit_title # monkey-patch reST parser to disable alphabetic and roman enumerated lists from docutils.parsers.rst.states import Body @@ -44,6 +46,16 @@ def issue_role(typ, rawtext, text, lineno, inliner, options={}, content=[]): return [refnode], [] +# 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], [] + + # Support for marking up implementation details from sphinx.util.compat import Directive @@ -72,6 +84,67 @@ class ImplementationDetail(Directive): return [pnode] +# Support for documenting decorators + +from sphinx import addnodes +from sphinx.domains.python import PyModulelevel, PyClassmember + +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 + +class PyDecoratorFunction(PyDecoratorMixin, PyModulelevel): + def run(self): + # a decorator function is a function after all + self.name = 'py:function' + return PyModulelevel.run(self) + +class PyDecoratorMethod(PyDecoratorMixin, PyClassmember): + def run(self): + self.name = 'py:method' + return PyClassmember.run(self) + + +# Support for documenting version of removal in deprecations + +from sphinx.locale import versionlabels +from sphinx.util.compat import Directive + +versionlabels['deprecated-removed'] = \ + 'Deprecated since version %s, will be removed in version %s' + +class DeprecatedRemoved(Directive): + has_content = True + required_arguments = 2 + optional_arguments = 1 + final_argument_whitespace = True + option_spec = {} + + 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 + if len(self.arguments) == 3: + inodes, messages = self.state.inline_text(self.arguments[2], + self.lineno+1) + node.extend(inodes) + if self.content: + self.state.nested_parse(self.content, self.content_offset, node) + ret = [node] + messages + else: + ret = [node] + env = self.state.document.settings.env + env.note_versionchange('deprecated', version[0], node, self.lineno) + return ret + + # Support for building "topic help" for pydoc pydoc_topic_labels = [ @@ -119,10 +192,10 @@ class PydocTopicsBuilder(Builder): for label in self.status_iterator(pydoc_topic_labels, 'building topics... ', length=len(pydoc_topic_labels)): - if label not in self.env.labels: + if label not in self.env.domaindata['std']['labels']: self.warn('label %r not in documentation' % label) continue - docname, labelid, sectname = self.env.labels[label] + docname, labelid, sectname = self.env.domaindata['std']['labels'][label] doctree = self.env.get_and_resolve_doctree(docname, self) document = new_document('<section node>') document.append(doctree.ids[labelid]) @@ -147,7 +220,6 @@ import suspicious # Support for documenting Opcodes import re -from sphinx import addnodes opcode_sig_re = re.compile(r'(\w+(?:\+\d)?)(?:\s*\((.*)\))?') @@ -165,11 +237,41 @@ def parse_opcode_signature(env, sig, signode): return opname.strip() +# Support for documenting pdb commands + +pdbcmd_sig_re = re.compile(r'([a-z()!]+)\s*(.*)') + +# later... +#pdbargs_tokens_re = re.compile(r'''[a-zA-Z]+ | # identifiers +# [.,:]+ | # punctuation +# [\[\]()] | # parens +# \s+ # whitespace +# ''', re.X) + +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 + + def setup(app): app.add_role('issue', issue_role) + app.add_role('source', source_role) app.add_directive('impl-detail', ImplementationDetail) + app.add_directive('deprecated-removed', DeprecatedRemoved) app.add_builder(PydocTopicsBuilder) app.add_builder(suspicious.CheckSuspiciousMarkupBuilder) app.add_description_unit('opcode', 'opcode', '%s (opcode)', parse_opcode_signature) + app.add_description_unit('pdbcommand', 'pdbcmd', '%s (pdb command)', + parse_pdb_command) app.add_description_unit('2to3fixer', '2to3fixer', '%s (2to3 fixer)') + app.add_directive_to_domain('py', 'decorator', PyDecoratorFunction) + app.add_directive_to_domain('py', 'decoratormethod', PyDecoratorMethod) diff --git a/Doc/tools/sphinxext/static/basic.css b/Doc/tools/sphinxext/static/basic.css index 2b47622..65aa5f1 100644 --- a/Doc/tools/sphinxext/static/basic.css +++ b/Doc/tools/sphinxext/static/basic.css @@ -253,8 +253,8 @@ table.docutils { table.docutils td, table.docutils th { padding: 2px 5px 2px 5px; - border-left: 0; - background-color: #eef; + border-left: 0; + background-color: #eef; } table.docutils td p.last, table.docutils th p.last { @@ -270,7 +270,7 @@ table.footnote td, table.footnote th { } table.docutils th { - border-top: 1px solid #cac; + border-top: 1px solid #cac; background-color: #ede; } @@ -280,7 +280,7 @@ th { } th.head { - text-align: center; + text-align: center; } /* -- other body styles ----------------------------------------------------- */ @@ -333,7 +333,7 @@ dl.glossary dt { font-style: italic; } -p.deprecated { +p.deprecated, p.deprecated-removed { background-color: #ffe4e4; border: 1px solid #f66; padding: 7px diff --git a/Doc/tools/sphinxext/susp-ignored.csv b/Doc/tools/sphinxext/susp-ignored.csv index 4d4db94..ef98091 100644 --- a/Doc/tools/sphinxext/susp-ignored.csv +++ b/Doc/tools/sphinxext/susp-ignored.csv @@ -186,6 +186,99 @@ documenting/fromlatex,152,:noindex,:noindex: documenting/fromlatex,162,.. describe:,.. describe:: a == b documenting/fromlatex,168,.. cmdoption:,.. cmdoption:: -O documenting/fromlatex,168,.. envvar:,.. envvar:: PYTHONINSPECT +documenting/markup,33,.. sectionauthor:,.. sectionauthor:: Guido van Rossum <guido@python.org> +documenting/markup,42,:mod,:mod:`parrot` -- Dead parrot access +documenting/markup,42,`,:mod:`parrot` -- Dead parrot access +documenting/markup,42,.. module:,.. module:: parrot +documenting/markup,42,:platform,":platform: Unix, Windows" +documenting/markup,42,:synopsis,:synopsis: Analyze and reanimate dead parrots. +documenting/markup,42,.. moduleauthor:,.. moduleauthor:: Eric Cleese <eric@python.invalid> +documenting/markup,42,.. moduleauthor:,.. moduleauthor:: John Idle <john@python.invalid> +documenting/markup,88,:noindex,:noindex: +documenting/markup,95,.. function:,.. function:: spam(eggs) +documenting/markup,95,:noindex,:noindex: +documenting/markup,101,.. method:,.. method:: FileInput.input(...) +documenting/markup,121,:function,c:function +documenting/markup,121,.. c:,".. c:function:: PyObject* PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)" +documenting/markup,121,::,".. c:function:: PyObject* PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)" +documenting/markup,131,:member,c:member +documenting/markup,131,.. c:,.. c:member:: PyObject* PyTypeObject.tp_bases +documenting/markup,131,::,.. c:member:: PyObject* PyTypeObject.tp_bases +documenting/markup,139,:macro,c:macro +documenting/markup,143,:type,c:type +documenting/markup,150,:var,c:var +documenting/markup,150,.. cvar:,.. cvar:: PyObject* PyClass_Type +documenting/markup,179,.. function:,".. function:: Timer.repeat([repeat=3[, number=1000000]])" +documenting/markup,210,.. decorator:,.. decorator:: removename +documenting/markup,210,.. decorator:,.. decorator:: setnewname(name) +documenting/markup,210,:func,:func: +documenting/markup,233,:meth,:meth: +documenting/markup,246,.. cmdoption:,.. cmdoption:: -m <module> +documenting/markup,264,.. describe:,.. describe:: opcode +documenting/markup,293,.. highlightlang:,.. highlightlang:: c +documenting/markup,313,.. literalinclude:,.. literalinclude:: example.py +documenting/markup,328,:rolename,:rolename:`content` +documenting/markup,328,`,:rolename:`content` +documenting/markup,333,:role,:role:`title <target>` +documenting/markup,333,`,:role:`title <target>` +documenting/markup,339,:meth,:meth:`~Queue.Queue.get` +documenting/markup,339,`,:meth:`~Queue.Queue.get` +documenting/markup,387,:func,:func:`filter` +documenting/markup,387,`,:func:`filter` +documenting/markup,387,:func,:func:`foo.filter` +documenting/markup,387,`,:func:`foo.filter` +documenting/markup,393,:func,:func:`open` +documenting/markup,393,`,:func:`open` +documenting/markup,393,:func,:func:`.open` +documenting/markup,393,`,:func:`.open` +documenting/markup,409,:data,c:data +documenting/markup,413,:func,c:func +documenting/markup,417,:macro,c:macro +documenting/markup,421,:type,c:type +documenting/markup,426,:member,c:member +documenting/markup,476,:file,... is installed in :file:`/usr/lib/python2.{x}/site-packages` ... +documenting/markup,476,`,... is installed in :file:`/usr/lib/python2.{x}/site-packages` ... +documenting/markup,495,:kbd,:kbd:`C-x C-f` +documenting/markup,495,`,:kbd:`C-x C-f` +documenting/markup,495,:kbd,:kbd:`Control-x Control-f` +documenting/markup,495,`,:kbd:`Control-x Control-f` +documenting/markup,509,:mailheader,:mailheader:`Content-Type` +documenting/markup,509,`,:mailheader:`Content-Type` +documenting/markup,518,:manpage,:manpage:`ls(1)` +documenting/markup,518,`,:manpage:`ls(1)` +documenting/markup,534,:menuselection,:menuselection:`Start --> Programs` +documenting/markup,534,`,:menuselection:`Start --> Programs` +documenting/markup,549,`,``code`` +documenting/markup,567,:file,:file: +documenting/markup,567,`,``code`` +documenting/markup,602,:ref,:ref:`label-name` +documenting/markup,602,`,:ref:`label-name` +documenting/markup,606,:ref,"It refers to the section itself, see :ref:`my-reference-label`." +documenting/markup,606,`,"It refers to the section itself, see :ref:`my-reference-label`." +documenting/markup,615,:ref,:ref: +documenting/markup,636,.. note:,.. note:: +documenting/markup,663,.. versionadded:,.. versionadded:: 3.1 +documenting/markup,688,::,.. impl-detail:: +documenting/markup,688,::,.. impl-detail:: This shortly mentions an implementation detail. +documenting/markup,708,.. seealso:,.. seealso:: +documenting/markup,708,:mod,Module :mod:`zipfile` +documenting/markup,708,`,Module :mod:`zipfile` +documenting/markup,708,:mod,Documentation of the :mod:`zipfile` standard module. +documenting/markup,708,`,Documentation of the :mod:`zipfile` standard module. +documenting/markup,708,`,"`GNU tar manual, Basic Tar Format <http://link>`_" +documenting/markup,722,.. centered:,.. centered:: +documenting/markup,767,.. toctree:,.. toctree:: +documenting/markup,767,:maxdepth,:maxdepth: 2 +documenting/markup,783,.. index:,.. index:: +documenting/markup,813,.. index:,".. index:: BNF, grammar, syntax, notation" +documenting/markup,844,`,"unaryneg ::= ""-"" `integer`" +documenting/markup,849,.. productionlist:,.. productionlist:: +documenting/markup,849,`,"try1_stmt: ""try"" "":"" `suite`" +documenting/markup,849,`,": (""except"" [`expression` ["","" `target`]] "":"" `suite`)+" +documenting/markup,849,`,": [""else"" "":"" `suite`]" +documenting/markup,849,`,": [""finally"" "":"" `suite`]" +documenting/markup,849,`,"try2_stmt: ""try"" "":"" `suite`" +documenting/markup,849,`,": ""finally"" "":"" `suite`" documenting/rest,33,`,``text`` documenting/rest,47,:rolename,:rolename:`content` documenting/rest,47,`,:rolename:`content` @@ -203,15 +296,15 @@ faq/windows,393,:REG,.py :REG_SZ: c:\<path to python>\python.exe -u %s %s library/bisect,32,:hi,all(val >= x for val in a[i:hi]) library/bisect,42,:hi,all(val > x for val in a[i:hi]) library/http.client,52,:port,host:port -library/nntplib,272,:bytes,:bytes -library/nntplib,272,:lines,:lines -library/nntplib,272,:lines,"['xref', 'from', ':lines', ':bytes', 'references', 'date', 'message-id', 'subject']" -library/nntplib,272,:bytes,"['xref', 'from', ':lines', ':bytes', 'references', 'date', 'message-id', 'subject']" +library/nntplib,,:bytes,:bytes +library/nntplib,,:lines,:lines +library/nntplib,,:lines,"['xref', 'from', ':lines', ':bytes', 'references', 'date', 'message-id', 'subject']" +library/nntplib,,:bytes,"['xref', 'from', ':lines', ':bytes', 'references', 'date', 'message-id', 'subject']" library/pickle,,:memory,"conn = sqlite3.connect("":memory:"")" library/profile,,:lineno,"(sort by filename:lineno)," library/socket,,::,"(10, 1, 6, '', ('2001:888:2000:d::a2', 80, 0, 0))]" -library/stdtypes,1026,:end,s[start:end] -library/stdtypes,1195,:end,s[start:end] +library/stdtypes,,:end,s[start:end] +library/stdtypes,,:end,s[start:end] library/urllib.request,,:close,Connection:close library/urllib.request,,:password,"""joe:password@python.org""" library/urllib.request,,:lang,"xmlns=""http://www.w3.org/1999/xhtml"" xml:lang=""en"" lang=""en"">\n\n<head>\n" @@ -228,85 +321,68 @@ whatsnew/2.7,862,::,"export PYTHONWARNINGS=all,error:::Cookie:0" whatsnew/2.7,862,:Cookie,"export PYTHONWARNINGS=all,error:::Cookie:0" whatsnew/2.7,1619,::,>>> urlparse.urlparse('http://[1080::8:800:200C:417A]/foo') whatsnew/2.7,1619,::,"ParseResult(scheme='http', netloc='[1080::8:800:200C:417A]'," -documenting/markup,33,.. sectionauthor:,.. sectionauthor:: Guido van Rossum <guido@python.org> -documenting/markup,42,:mod,:mod:`parrot` -- Dead parrot access -documenting/markup,42,`,:mod:`parrot` -- Dead parrot access -documenting/markup,42,.. module:,.. module:: parrot -documenting/markup,42,:platform,":platform: Unix, Windows" -documenting/markup,42,:synopsis,:synopsis: Analyze and reanimate dead parrots. -documenting/markup,42,.. moduleauthor:,.. moduleauthor:: Eric Cleese <eric@python.invalid> -documenting/markup,42,.. moduleauthor:,.. moduleauthor:: John Idle <john@python.invalid> -documenting/markup,88,:noindex,:noindex: -documenting/markup,95,.. function:,.. function:: spam(eggs) -documenting/markup,95,:noindex,:noindex: -documenting/markup,101,.. method:,.. method:: FileInput.input(...) -documenting/markup,121,.. cfunction:,".. cfunction:: PyObject* PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)" -documenting/markup,131,.. cmember:,.. cmember:: PyObject* PyTypeObject.tp_bases -documenting/markup,150,.. cvar:,.. cvar:: PyObject* PyClass_Type -documenting/markup,179,.. function:,".. function:: Timer.repeat([repeat=3[, number=1000000]])" -documenting/markup,209,.. cmdoption:,.. cmdoption:: -m <module> -documenting/markup,227,.. describe:,.. describe:: opcode -documenting/markup,256,.. highlightlang:,.. highlightlang:: c -documenting/markup,276,.. literalinclude:,.. literalinclude:: example.py -documenting/markup,291,:rolename,:rolename:`content` -documenting/markup,291,`,:rolename:`content` -documenting/markup,296,:role,:role:`title <target>` -documenting/markup,296,`,:role:`title <target>` -documenting/markup,302,:meth,:meth:`~Queue.Queue.get` -documenting/markup,302,`,:meth:`~Queue.Queue.get` -documenting/markup,350,:func,:func:`filter` -documenting/markup,350,`,:func:`filter` -documenting/markup,350,:func,:func:`foo.filter` -documenting/markup,350,`,:func:`foo.filter` -documenting/markup,356,:func,:func:`open` -documenting/markup,356,`,:func:`open` -documenting/markup,356,:func,:func:`.open` -documenting/markup,356,`,:func:`.open` -documenting/markup,435,:file,... is installed in :file:`/usr/lib/python2.{x}/site-packages` ... -documenting/markup,435,`,... is installed in :file:`/usr/lib/python2.{x}/site-packages` ... -documenting/markup,454,:kbd,:kbd:`C-x C-f` -documenting/markup,454,`,:kbd:`C-x C-f` -documenting/markup,454,:kbd,:kbd:`Control-x Control-f` -documenting/markup,454,`,:kbd:`Control-x Control-f` -documenting/markup,468,:mailheader,:mailheader:`Content-Type` -documenting/markup,468,`,:mailheader:`Content-Type` -documenting/markup,477,:manpage,:manpage:`ls(1)` -documenting/markup,477,`,:manpage:`ls(1)` -documenting/markup,493,:menuselection,:menuselection:`Start --> Programs` -documenting/markup,493,`,:menuselection:`Start --> Programs` -documenting/markup,508,`,``code`` -documenting/markup,526,:file,:file: -documenting/markup,526,`,``code`` -documenting/markup,561,:ref,:ref:`label-name` -documenting/markup,561,`,:ref:`label-name` -documenting/markup,565,:ref,"It refers to the section itself, see :ref:`my-reference-label`." -documenting/markup,565,`,"It refers to the section itself, see :ref:`my-reference-label`." -documenting/markup,574,:ref,:ref: -documenting/markup,595,.. note:,.. note:: -documenting/markup,622,.. versionadded:,.. versionadded:: 3.1 -documenting/markup,647,::,.. impl-detail:: -documenting/markup,647,::,.. impl-detail:: This shortly mentions an implementation detail. -documenting/markup,667,.. seealso:,.. seealso:: -documenting/markup,667,:mod,Module :mod:`zipfile` -documenting/markup,667,`,Module :mod:`zipfile` -documenting/markup,667,:mod,Documentation of the :mod:`zipfile` standard module. -documenting/markup,667,`,Documentation of the :mod:`zipfile` standard module. -documenting/markup,667,`,"`GNU tar manual, Basic Tar Format <http://link>`_" -documenting/markup,681,.. centered:,.. centered:: -documenting/markup,726,.. toctree:,.. toctree:: -documenting/markup,726,:maxdepth,:maxdepth: 2 -documenting/markup,742,.. index:,.. index:: -documenting/markup,772,.. index:,".. index:: BNF, grammar, syntax, notation" -documenting/markup,803,`,"unaryneg ::= ""-"" `integer`" -documenting/markup,808,.. productionlist:,.. productionlist:: -documenting/markup,808,`,"try1_stmt: ""try"" "":"" `suite`" -documenting/markup,808,`,": (""except"" [`expression` ["","" `target`]] "":"" `suite`)+" -documenting/markup,808,`,": [""else"" "":"" `suite`]" -documenting/markup,808,`,": [""finally"" "":"" `suite`]" -documenting/markup,808,`,"try2_stmt: ""try"" "":"" `suite`" -documenting/markup,808,`,": ""finally"" "":"" `suite`" -library/importlib,396,`,The keys are the module names -- packages must end in ``.__init__``. -library/importlib,396,`,"name with ``.__init__`` appended to it.""""""" -library/importlib,396,`,# ``__init__``. -library/socket,249,::,"(10, 1, 6, '', ('2001:888:2000:d::a2', 80, 0, 0))]" -library/stdtypes,860,:end,s[start:end] +library/configparser,,`,# Set the optional `raw` argument of get() to True if you wish to disable +library/configparser,,`,# The optional `vars` argument is a dict with members that will take +library/configparser,,`,# The optional `fallback` argument can be used to provide a fallback value +library/configparser,,:option,${section:option} +library/configparser,,:system,path: ${Common:system_dir}/Library/Frameworks/ +library/configparser,,:home,my_dir: ${Common:home_dir}/twosheds +library/configparser,,:path,python_dir: ${Frameworks:path}/Python/Versions/${Frameworks:Python} +library/configparser,,:Python,python_dir: ${Frameworks:path}/Python/Versions/${Frameworks:Python} +library/pdb,,:lineno,[filename:lineno | bpnumber [bpnumber ...]] +library/pdb,,:lineno,filename:lineno +library/logging,,:Watch,WARNING:root:Watch out! +library/logging,,:So,INFO:root:So should this +library/logging,,:Started,INFO:root:Started +library/logging,,:Doing,INFO:root:Doing something +library/logging,,:Finished,INFO:root:Finished +library/logging,,:Look,WARNING:root:Look before you leap! +library/logging,,:So,INFO:So should this +library/logging,,:logger,severity:logger name:message +library/logging,,:message,severity:logger name:message +whatsnew/3.2,,:directory,... ${buildout:directory}/downloads/dist +whatsnew/3.2,,:location,... zope9-location = ${zope9:location} +whatsnew/3.2,,:prefix,... zope-conf = ${custom:prefix}/etc/zope.conf +howto/logging,,:root,WARNING:root:Watch out! +howto/logging,,:Watch,WARNING:root:Watch out! +howto/logging,,:root,DEBUG:root:This message should go to the log file +howto/logging,,:This,DEBUG:root:This message should go to the log file +howto/logging,,:root,INFO:root:So should this +howto/logging,,:So,INFO:root:So should this +howto/logging,,:root,"WARNING:root:And this, too" +howto/logging,,:And,"WARNING:root:And this, too" +howto/logging,,:root,INFO:root:Started +howto/logging,,:Started,INFO:root:Started +howto/logging,,:root,INFO:root:Doing something +howto/logging,,:Doing,INFO:root:Doing something +howto/logging,,:root,INFO:root:Finished +howto/logging,,:Finished,INFO:root:Finished +howto/logging,,:root,WARNING:root:Look before you leap! +howto/logging,,:Look,WARNING:root:Look before you leap! +howto/logging,,:This,DEBUG:This message should appear on the console +howto/logging,,:So,INFO:So should this +howto/logging,,:And,"WARNING:And this, too" +howto/logging,,:logger,severity:logger name:message +howto/logging,,:message,severity:logger name:message +library/logging.handlers,,:port,host:port +documenting/markup,613,`,:ref:`link text <reference-label>` +library/imaplib,116,:MM,"""DD-Mmm-YYYY HH:MM:SS" +library/imaplib,116,:SS,"""DD-Mmm-YYYY HH:MM:SS" +whatsnew/3.2,,::,"$ export PYTHONWARNINGS='ignore::RuntimeWarning::,once::UnicodeWarning::'" +howto/pyporting,75,::,# make sure to use :: Python *and* :: Python :: 3 so +howto/pyporting,75,::,"'Programming Language :: Python'," +howto/pyporting,75,::,'Programming Language :: Python :: 3' +whatsnew/3.2,,:gz,">>> with tarfile.open(name='myarchive.tar.gz', mode='w:gz') as tf:" +whatsnew/3.2,,:directory,${buildout:directory}/downloads/dist +whatsnew/3.2,,:location,zope9-location = ${zope9:location} +whatsnew/3.2,,:prefix,zope-conf = ${custom:prefix}/etc/zope.conf +whatsnew/3.2,,:beef,>>> urllib.parse.urlparse('http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]/foo/') +whatsnew/3.2,,:cafe,>>> urllib.parse.urlparse('http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]/foo/') +whatsnew/3.2,,:affe,>>> urllib.parse.urlparse('http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]/foo/') +whatsnew/3.2,,:deaf,>>> urllib.parse.urlparse('http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]/foo/') +whatsnew/3.2,,:feed,>>> urllib.parse.urlparse('http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]/foo/') +whatsnew/3.2,,:beef,"netloc='[dead:beef:cafe:5417:affe:8FA3:deaf:feed]'," +whatsnew/3.2,,:cafe,"netloc='[dead:beef:cafe:5417:affe:8FA3:deaf:feed]'," +whatsnew/3.2,,:affe,"netloc='[dead:beef:cafe:5417:affe:8FA3:deaf:feed]'," +whatsnew/3.2,,:deaf,"netloc='[dead:beef:cafe:5417:affe:8FA3:deaf:feed]'," +whatsnew/3.2,,:feed,"netloc='[dead:beef:cafe:5417:affe:8FA3:deaf:feed]'," diff --git a/Doc/tools/sphinxext/suspicious.py b/Doc/tools/sphinxext/suspicious.py index f15e931b..888b231 100644 --- a/Doc/tools/sphinxext/suspicious.py +++ b/Doc/tools/sphinxext/suspicious.py @@ -49,13 +49,15 @@ import sys from docutils import nodes from sphinx.builders import Builder -detect_all = re.compile(ur''' +detect_all = re.compile(r''' ::(?=[^=])| # two :: (but NOT ::=) :[a-zA-Z][a-zA-Z0-9]+| # :foo `| # ` (seldom used by itself) (?<!\.)\.\.[ \t]*\w+: # .. foo: (but NOT ... else:) ''', re.UNICODE | re.VERBOSE).finditer +py3 = sys.version_info >= (3, 0) + class Rule: def __init__(self, docname, lineno, issue, line): @@ -136,7 +138,11 @@ class CheckSuspiciousMarkupBuilder(Builder): if not self.any_issue: self.info() self.any_issue = True self.write_log_entry(lineno, issue, text) - self.warn('[%s:%d] "%s" found in "%-.120s"' % ( + if py3: + self.warn('[%s:%d] "%s" found in "%-.120s"' % + (self.docname, lineno, issue, text)) + else: + self.warn('[%s:%d] "%s" found in "%-.120s"' % ( self.docname.encode(sys.getdefaultencoding(),'replace'), lineno, issue.encode(sys.getdefaultencoding(),'replace'), @@ -144,13 +150,19 @@ class CheckSuspiciousMarkupBuilder(Builder): self.app.statuscode = 1 def write_log_entry(self, lineno, issue, text): - f = open(self.log_file_name, 'ab') - writer = csv.writer(f, dialect) - writer.writerow([self.docname.encode('utf-8'), - lineno, - issue.encode('utf-8'), - text.strip().encode('utf-8')]) - f.close() + if py3: + f = open(self.log_file_name, 'a') + writer = csv.writer(f, dialect) + writer.writerow([self.docname, lineno, issue, text.strip()]) + f.close() + else: + f = open(self.log_file_name, 'ab') + writer = csv.writer(f, dialect) + writer.writerow([self.docname.encode('utf-8'), + lineno, + issue.encode('utf-8'), + text.strip().encode('utf-8')]) + f.close() def load_rules(self, filename): """Load database of previously ignored issues. @@ -160,18 +172,26 @@ class CheckSuspiciousMarkupBuilder(Builder): """ self.info("loading ignore rules... ", nonl=1) self.rules = rules = [] - try: f = open(filename, 'rb') - except IOError: return + try: + if py3: + f = open(filename, 'r') + else: + f = open(filename, 'rb') + except IOError: + return for i, row in enumerate(csv.reader(f)): if len(row) != 4: raise ValueError( "wrong format in %s, line %d: %s" % (filename, i+1, row)) docname, lineno, issue, text = row - docname = docname.decode('utf-8') - if lineno: lineno = int(lineno) - else: lineno = None - issue = issue.decode('utf-8') - text = text.decode('utf-8') + if lineno: + lineno = int(lineno) + else: + lineno = None + if not py3: + docname = docname.decode('utf-8') + issue = issue.decode('utf-8') + text = text.decode('utf-8') rule = Rule(docname, lineno, issue, text) rules.append(rule) f.close() |