Changeset 388 for python/vendor/current/Doc/tools
- Timestamp:
- Mar 19, 2014, 11:11:30 AM (11 years ago)
- Location:
- python/vendor/current/Doc/tools
- Files:
-
- 4 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
python/vendor/current/Doc/tools/sphinx-build.py
r2 r388 4 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 5 5 6 :copyright: 2007 by Georg Brandl.6 :copyright: 2007-2010 by Georg Brandl. 7 7 :license: Python license. 8 8 """ 9 9 10 10 import sys 11 import warnings 12 13 # Get rid of UserWarnings reported by pkg_resources. 14 warnings.filterwarnings('ignore', category=UserWarning, module='jinja2') 11 15 12 16 if __name__ == '__main__': -
python/vendor/current/Doc/tools/sphinxext/download.html
r2 r388 36 36 </table> 37 37 38 <p>These archives contain all the content in the documentation.</p> 38 39 39 <p>These archives contain all the content in the documentation.</p> 40 <p>HTML Help (<tt>.chm</tt>) files are made available in the "Windows" section 41 on the <a href="http://python.org/download/releases/{{ release[:5] }}/">Python 42 download page</a>.</p> 43 40 44 41 45 <h2>Unpacking</h2> -
python/vendor/current/Doc/tools/sphinxext/indexcontent.html
r2 r388 8 8 <p class="biglink"><a class="biglink" href="{{ pathto("tutorial/index") }}">Tutorial</a><br/> 9 9 <span class="linkdescr">start here</span></p> 10 <p class="biglink"><a class="biglink" href="{{ pathto("using/index") }}">Using Python</a><br/>11 <span class="linkdescr">how to use Python on different platforms</span></p>12 10 <p class="biglink"><a class="biglink" href="{{ pathto("library/index") }}">Library Reference</a><br/> 13 11 <span class="linkdescr">keep this under your pillow</span></p> 14 12 <p class="biglink"><a class="biglink" href="{{ pathto("reference/index") }}">Language Reference</a><br/> 15 13 <span class="linkdescr">describes syntax and language elements</span></p> 14 <p class="biglink"><a class="biglink" href="{{ pathto("using/index") }}">Python Setup and Usage</a><br/> 15 <span class="linkdescr">how to use Python on different platforms</span></p> 16 16 <p class="biglink"><a class="biglink" href="{{ pathto("howto/index") }}">Python HOWTOs</a><br/> 17 17 <span class="linkdescr">in-depth documents on specific topics</span></p> … … 25 25 <p class="biglink"><a class="biglink" href="{{ pathto("distutils/index") }}">Distributing Python Modules</a><br/> 26 26 <span class="linkdescr">sharing modules with others</span></p> 27 <p class="biglink"><a class="biglink" href="{{ pathto("documenting/index") }}">Documenting Python</a><br/>28 <span class="linkdescr">guide for documentation authors</span></p>29 27 <p class="biglink"><a class="biglink" href="{{ pathto("faq/index") }}">FAQs</a><br/> 30 28 <span class="linkdescr">frequently asked questions (with answers!)</span></p> … … 35 33 <table class="contentstable" align="center"><tr> 36 34 <td width="50%"> 37 <p class="biglink"><a class="biglink" href="{{ pathto(" modindex") }}">Global Module Index</a><br/>35 <p class="biglink"><a class="biglink" href="{{ pathto("py-modindex") }}">Global Module Index</a><br/> 38 36 <span class="linkdescr">quick access to all modules</span></p> 39 37 <p class="biglink"><a class="biglink" href="{{ pathto("genindex") }}">General Index</a><br/> -
python/vendor/current/Doc/tools/sphinxext/indexsidebar.html
r2 r388 3 3 <h3>Docs for other versions</h3> 4 4 <ul> 5 <li><a href="http://docs.python.org/2.7/">Python 2.7 (in development)</a></li> 6 <li><a href="http://docs.python.org/3.1/">Python 3.1 (stable)</a></li> 7 <li><a href="http://docs.python.org/dev/py3k/">Python 3.2 (in development)</a></li> 5 <li><a href="http://docs.python.org/3.3/">Python 3.3 (stable)</a></li> 6 <li><a href="http://docs.python.org/3.4/">Python 3.4 (in development)</a></li> 8 7 <li><a href="http://www.python.org/doc/versions/">Old versions</a></li> 9 8 </ul> … … 12 11 <ul> 13 12 {# XXX: many of these should probably be merged in the main docs #} 14 <li><a href="http://www.python.org/doc/faq/">FAQs</a></li>15 <li><a href="http://www.python.org/doc/essays/">Guido's Essays</a></li>16 <li><a href="http://www.python.org/doc/newstyle/">New-style Classes</a></li>17 13 <li><a href="http://www.python.org/dev/peps/">PEP Index</a></li> 18 14 <li><a href="http://wiki.python.org/moin/BeginnersGuide">Beginner's Guide</a></li> 19 15 <li><a href="http://wiki.python.org/moin/PythonBooks">Book List</a></li> 20 16 <li><a href="http://www.python.org/doc/av/">Audio/Visual Talks</a></li> 21 <li><a href="http://www.python.org/doc/other/">Other Doc Collections</a></li>22 17 </ul> -
python/vendor/current/Doc/tools/sphinxext/layout.html
r2 r388 3 3 <li><img src="{{ pathto('_static/py.png', 1) }}" alt="" 4 4 style="vertical-align: middle; margin-top: -1px"/></li> 5 <li><a href="{{ pathto('index') }}">{{ shorttitle }}</a>{{ reldelim1 }}</li> 5 <li><a href="http://www.python.org/">Python</a>{{ reldelim1 }}</li> 6 <li> 7 {%- if versionswitcher is defined %} 8 <span class="version_switcher_placeholder">{{ release }}</span> 9 <a href="{{ pathto('index') }}">Documentation</a>{{ reldelim1 }} 10 {%- else %} 11 <a href="{{ pathto('index') }}">{{ shorttitle }}</a>{{ reldelim1 }} 12 {%- endif %} 13 </li> 6 14 {% endblock %} 7 15 {% block extrahead %} 8 16 <link rel="shortcut icon" type="image/png" href="{{ pathto('_static/py.png', 1) }}" /> 17 {% if not embedded %}<script type="text/javascript" src="{{ pathto('_static/copybutton.js', 1) }}"></script>{% endif %} 18 {% if versionswitcher is defined and not embedded %}<script type="text/javascript" src="{{ pathto('_static/version_switch.js', 1) }}"></script>{% endif %} 9 19 {{ super() }} 10 20 {% endblock %} … … 13 23 © <a href="{{ pathto('copyright') }}">Copyright</a> {{ copyright|e }}. 14 24 <br /> 15 The Python Software Foundation is a non-profit corporation. 25 The Python Software Foundation is a non-profit corporation. 16 26 <a href="http://www.python.org/psf/donations/">Please donate.</a> 17 27 <br /> 18 28 Last updated on {{ last_updated|e }}. 29 <a href="{{ pathto('bugs') }}">Found a bug</a>? 30 <br /> 19 31 Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> {{ sphinx_version|e }}. 20 32 </div> 21 33 {% endblock %} 34 {% block sidebarsourcelink %} 35 {%- if show_source and has_source and sourcename %} 36 <h3>{{ _('This Page') }}</h3> 37 <ul class="this-page-menu"> 38 <li><a href="{{ pathto('bugs') }}">Report a Bug</a></li> 39 <li><a href="{{ pathto('_sources/' + sourcename, true)|e }}" 40 rel="nofollow">Show Source</a></li> 41 </ul> 42 {%- endif %} 43 {% endblock %} -
python/vendor/current/Doc/tools/sphinxext/patchlevel.py
r2 r388 42 42 'PY_RELEASE_LEVEL_ALPHA': 'a', 43 43 'PY_RELEASE_LEVEL_BETA': 'b', 44 'PY_RELEASE_LEVEL_GAMMA': ' c',44 'PY_RELEASE_LEVEL_GAMMA': 'rc', 45 45 } 46 46 if level != 'PY_RELEASE_LEVEL_FINAL': -
python/vendor/current/Doc/tools/sphinxext/pyspecific.py
r2 r388 6 6 Sphinx extension with Python doc-specific markup. 7 7 8 :copyright: 2008 , 2009by Georg Brandl.8 :copyright: 2008-2013 by Georg Brandl. 9 9 :license: Python license. 10 10 """ 11 11 12 12 ISSUE_URI = 'http://bugs.python.org/issue%s' 13 SOURCE_URI = 'http://hg.python.org/cpython/file/2.7/%s' 13 14 14 15 from docutils import nodes, utils 16 17 import sphinx 18 from sphinx.util.nodes import split_explicit_title 19 from sphinx.writers.html import HTMLTranslator 20 from sphinx.writers.latex import LaTeXTranslator 21 from sphinx.locale import versionlabels 15 22 16 23 # monkey-patch reST parser to disable alphabetic and roman enumerated lists … … 21 28 Body.enum.converters['upperroman'] = lambda x: None 22 29 23 # monkey-patch HTML translator to give versionmodified paragraphs a class 24 def new_visit_versionmodified(self, node): 25 self.body.append(self.starttag(node, 'p', CLASS=node['type'])) 26 text = versionlabels[node['type']] % node['version'] 27 if len(node): 28 text += ': ' 29 else: 30 text += '.' 31 self.body.append('<span class="versionmodified">%s</span>' % text) 32 33 from sphinx.writers.html import HTMLTranslator 34 from sphinx.locale import versionlabels 35 HTMLTranslator.visit_versionmodified = new_visit_versionmodified 30 if sphinx.__version__[:3] < '1.2': 31 # monkey-patch HTML translator to give versionmodified paragraphs a class 32 def new_visit_versionmodified(self, node): 33 self.body.append(self.starttag(node, 'p', CLASS=node['type'])) 34 text = versionlabels[node['type']] % node['version'] 35 if len(node): 36 text += ': ' 37 else: 38 text += '.' 39 self.body.append('<span class="versionmodified">%s</span>' % text) 40 HTMLTranslator.visit_versionmodified = new_visit_versionmodified 41 42 # monkey-patch HTML and LaTeX translators to keep doctest blocks in the 43 # doctest docs themselves 44 orig_visit_literal_block = HTMLTranslator.visit_literal_block 45 def new_visit_literal_block(self, node): 46 meta = self.builder.env.metadata[self.builder.current_docname] 47 old_trim_doctest_flags = self.highlighter.trim_doctest_flags 48 if 'keepdoctest' in meta: 49 self.highlighter.trim_doctest_flags = False 50 try: 51 orig_visit_literal_block(self, node) 52 finally: 53 self.highlighter.trim_doctest_flags = old_trim_doctest_flags 54 55 HTMLTranslator.visit_literal_block = new_visit_literal_block 56 57 orig_depart_literal_block = LaTeXTranslator.depart_literal_block 58 def new_depart_literal_block(self, node): 59 meta = self.builder.env.metadata[self.curfilestack[-1]] 60 old_trim_doctest_flags = self.highlighter.trim_doctest_flags 61 if 'keepdoctest' in meta: 62 self.highlighter.trim_doctest_flags = False 63 try: 64 orig_depart_literal_block(self, node) 65 finally: 66 self.highlighter.trim_doctest_flags = old_trim_doctest_flags 67 68 LaTeXTranslator.depart_literal_block = new_depart_literal_block 36 69 37 70 # Support for marking up and linking to bugs.python.org issues … … 41 74 text = 'issue ' + issue 42 75 refnode = nodes.reference(text, text, refuri=ISSUE_URI % issue) 76 return [refnode], [] 77 78 79 # Support for linking to Python source files easily 80 81 def source_role(typ, rawtext, text, lineno, inliner, options={}, content=[]): 82 has_t, title, target = split_explicit_title(text) 83 title = utils.unescape(title) 84 target = utils.unescape(target) 85 refnode = nodes.reference(title, title, refuri=SOURCE_URI % target) 43 86 return [refnode], [] 44 87 … … 72 115 73 116 117 # Support for documenting decorators 118 119 from sphinx import addnodes 120 from sphinx.domains.python import PyModulelevel, PyClassmember 121 122 class PyDecoratorMixin(object): 123 def handle_signature(self, sig, signode): 124 ret = super(PyDecoratorMixin, self).handle_signature(sig, signode) 125 signode.insert(0, addnodes.desc_addname('@', '@')) 126 return ret 127 128 def needs_arglist(self): 129 return False 130 131 class PyDecoratorFunction(PyDecoratorMixin, PyModulelevel): 132 def run(self): 133 # a decorator function is a function after all 134 self.name = 'py:function' 135 return PyModulelevel.run(self) 136 137 class PyDecoratorMethod(PyDecoratorMixin, PyClassmember): 138 def run(self): 139 self.name = 'py:method' 140 return PyClassmember.run(self) 141 142 143 # Support for documenting version of removal in deprecations 144 145 from sphinx.locale import versionlabels 146 from sphinx.util.compat import Directive 147 148 versionlabels['deprecated-removed'] = \ 149 'Deprecated since version %s, will be removed in version %s' 150 151 class DeprecatedRemoved(Directive): 152 has_content = True 153 required_arguments = 2 154 optional_arguments = 1 155 final_argument_whitespace = True 156 option_spec = {} 157 158 def run(self): 159 node = addnodes.versionmodified() 160 node.document = self.state.document 161 node['type'] = 'deprecated-removed' 162 version = (self.arguments[0], self.arguments[1]) 163 node['version'] = version 164 if len(self.arguments) == 3: 165 inodes, messages = self.state.inline_text(self.arguments[2], 166 self.lineno+1) 167 node.extend(inodes) 168 if self.content: 169 self.state.nested_parse(self.content, self.content_offset, node) 170 ret = [node] + messages 171 else: 172 ret = [node] 173 env = self.state.document.settings.env 174 env.note_versionchange('deprecated', version[0], node, self.lineno) 175 return ret 176 177 74 178 # Support for building "topic help" for pydoc 75 179 … … 78 182 'attribute-access', 'attribute-references', 'augassign', 'binary', 79 183 'bitwise', 'bltin-code-objects', 'bltin-ellipsis-object', 80 'bltin-file-objects', 'bltin-null-object', 'bltin-type-objects', 'booleans', 81 'break', 'callable-types', 'calls', 'class', 'coercion-rules', 82 'comparisons', 'compound', 'context-managers', 'continue', 'conversions', 83 'customization', 'debugger', 'del', 'dict', 'dynamic-features', 'else', 84 'exceptions', 'exec', 'execmodel', 'exprlists', 'floating', 'for', 85 'formatstrings', 'function', 'global', 'id-classes', 'identifiers', 'if', 86 'imaginary', 'import', 'in', 'integers', 'lambda', 'lists', 'naming', 87 'numbers', 'numeric-types', 'objects', 'operator-summary', 'pass', 'power', 88 'print', 'raise', 'return', 'sequence-methods', 'sequence-types', 89 'shifting', 'slicings', 'specialattrs', 'specialnames', 90 'string-conversions', 'string-methods', 'strings', 'subscriptions', 'truth', 91 'try', 'types', 'typesfunctions', 'typesmapping', 'typesmethods', 92 'typesmodules', 'typesseq', 'typesseq-mutable', 'unary', 'while', 'with', 93 'yield' 184 'bltin-null-object', 'bltin-type-objects', 'booleans', 185 'break', 'callable-types', 'calls', 'class', 'comparisons', 'compound', 186 'context-managers', 'continue', 'conversions', 'customization', 'debugger', 187 'del', 'dict', 'dynamic-features', 'else', 'exceptions', 'execmodel', 188 'exprlists', 'floating', 'for', 'formatstrings', 'function', 'global', 189 'id-classes', 'identifiers', 'if', 'imaginary', 'import', 'in', 'integers', 190 'lambda', 'lists', 'naming', 'numbers', 'numeric-types', 191 'objects', 'operator-summary', 'pass', 'power', 'raise', 'return', 192 'sequence-types', 'shifting', 'slicings', 'specialattrs', 'specialnames', 193 'string-methods', 'strings', 'subscriptions', 'truth', 'try', 'types', 194 'typesfunctions', 'typesmapping', 'typesmethods', 'typesmodules', 195 'typesseq', 'typesseq-mutable', 'unary', 'while', 'with', 'yield' 94 196 ] 95 197 … … 100 202 from docutils.utils import new_document 101 203 102 try: 103 from sphinx.builders import Builder 104 except ImportError: 105 # using Sphinx < 0.6, which has a different package layout 106 from sphinx.builder import Builder 107 # monkey-patch toctree directive to accept (and ignore) the :numbered: flag 108 from sphinx.directives.other import toctree_directive 109 toctree_directive.options['numbered'] = toctree_directive.options['glob'] 110 111 try: 112 from sphinx.writers.text import TextWriter 113 except ImportError: 114 from sphinx.textwriter import TextWriter 204 from sphinx.builders import Builder 205 from sphinx.writers.text import TextWriter 115 206 116 207 … … 129 220 def write(self, *ignored): 130 221 writer = TextWriter(self) 131 for label in self.status_iterator(pydoc_topic_labels, 'building topics... '): 132 if label not in self.env.labels: 222 for label in self.status_iterator(pydoc_topic_labels, 223 'building topics... ', 224 length=len(pydoc_topic_labels)): 225 if label not in self.env.domaindata['std']['labels']: 133 226 self.warn('label %r not in documentation' % label) 134 227 continue 135 docname, labelid, sectname = self.env. labels[label]228 docname, labelid, sectname = self.env.domaindata['std']['labels'][label] 136 229 doctree = self.env.get_and_resolve_doctree(docname, self) 137 230 document = new_document('<section node>') … … 139 232 destination = StringOutput(encoding='utf-8') 140 233 writer.write(document, destination) 141 self.topics[label] = writer.output234 self.topics[label] = str(writer.output) 142 235 143 236 def finish(self): 144 f = open(path.join(self.outdir, ' pydoc_topics.py'), 'w')237 f = open(path.join(self.outdir, 'topics.py'), 'w') 145 238 try: 146 239 f.write('# Autogenerated by Sphinx on %s\n' % asctime()) … … 158 251 159 252 import re 160 from sphinx import addnodes 161 162 opcode_sig_re = re.compile(r'(\w+(?:\+\d)?)\s*\((.*)\)') 253 254 opcode_sig_re = re.compile(r'(\w+(?:\+\d)?)(?:\s*\((.*)\))?') 163 255 164 256 def parse_opcode_signature(env, sig, signode): … … 169 261 opname, arglist = m.groups() 170 262 signode += addnodes.desc_name(opname, opname) 171 paramlist = addnodes.desc_parameterlist() 172 signode += paramlist 173 paramlist += addnodes.desc_parameter(arglist, arglist) 263 if arglist is not None: 264 paramlist = addnodes.desc_parameterlist() 265 signode += paramlist 266 paramlist += addnodes.desc_parameter(arglist, arglist) 174 267 return opname.strip() 268 269 270 # Support for documenting pdb commands 271 272 pdbcmd_sig_re = re.compile(r'([a-z()!]+)\s*(.*)') 273 274 # later... 275 #pdbargs_tokens_re = re.compile(r'''[a-zA-Z]+ | # identifiers 276 # [.,:]+ | # punctuation 277 # [\[\]()] | # parens 278 # \s+ # whitespace 279 # ''', re.X) 280 281 def parse_pdb_command(env, sig, signode): 282 """Transform a pdb command signature into RST nodes.""" 283 m = pdbcmd_sig_re.match(sig) 284 if m is None: 285 raise ValueError 286 name, args = m.groups() 287 fullname = name.replace('(', '').replace(')', '') 288 signode += addnodes.desc_name(name, name) 289 if args: 290 signode += addnodes.desc_addname(' '+args, ' '+args) 291 return fullname 175 292 176 293 177 294 def setup(app): 178 295 app.add_role('issue', issue_role) 296 app.add_role('source', source_role) 179 297 app.add_directive('impl-detail', ImplementationDetail) 298 app.add_directive('deprecated-removed', DeprecatedRemoved) 180 299 app.add_builder(PydocTopicsBuilder) 181 300 app.add_builder(suspicious.CheckSuspiciousMarkupBuilder) 182 301 app.add_description_unit('opcode', 'opcode', '%s (opcode)', 183 302 parse_opcode_signature) 303 app.add_description_unit('pdbcommand', 'pdbcmd', '%s (pdb command)', 304 parse_pdb_command) 184 305 app.add_description_unit('2to3fixer', '2to3fixer', '%s (2to3 fixer)') 306 app.add_directive_to_domain('py', 'decorator', PyDecoratorFunction) 307 app.add_directive_to_domain('py', 'decoratormethod', PyDecoratorMethod) -
python/vendor/current/Doc/tools/sphinxext/static/basic.css
r2 r388 39 39 40 40 div.sphinxsidebarwrapper { 41 position: relative; 42 top: 0; 41 43 padding: 10px 5px 0 10px; 44 word-wrap: break-word; 42 45 } 43 46 … … 254 257 table.docutils td, table.docutils th { 255 258 padding: 2px 5px 2px 5px; 256 border-left: 0; 257 background-color: #eef; 259 border-left: 0; 260 background-color: #eef; 261 } 262 263 table.docutils td p.last, table.docutils th p.last { 264 margin-bottom: 0; 258 265 } 259 266 … … 267 274 268 275 table.docutils th { 269 border-top: 1px solid #cac; 276 border-top: 1px solid #cac; 270 277 background-color: #ede; 271 278 } … … 277 284 278 285 th.head { 279 text-align: center; 286 text-align: center; 280 287 } 281 288 … … 330 337 } 331 338 332 p.deprecated {339 .deprecated { 333 340 background-color: #ffe4e4; 334 341 border: 1px solid #f66; 335 padding: 7px 342 padding: 7px; 343 } 344 345 div.deprecated p { 346 margin-bottom: 0; 336 347 } 337 348 … … 343 354 344 355 .footnote:target { 345 background-color: #ffa 356 background-color: #ffa; 346 357 } 347 358 … … 365 376 pre { 366 377 overflow: auto; 378 overflow-y: hidden; 367 379 } 368 380 -
python/vendor/current/Doc/tools/sphinxext/susp-ignored.csv
r2 r388 1 1 c-api/arg,,:ref,"PyArg_ParseTuple(args, ""O|O:ref"", &object, &callback)" 2 2 c-api/list,,:high,list[low:high] 3 c-api/list,,:high,list[low:high] = itemlist4 3 c-api/sequence,,:i2,o[i1:i2] 5 c-api/sequence,,:i2,o[i1:i2] = v6 c-api/sequence,,:i2,del o[i1:i2]7 4 c-api/unicode,,:end,str[start:end] 8 distutils/apiref,,:action,http://pypi.python.org/pypi?:action=list_classifiers9 5 distutils/setupscript,,::, 10 6 extending/embedding,,:numargs,"if(!PyArg_ParseTuple(args, "":numargs""))" … … 13 9 extending/newtypes,,:call,"if (!PyArg_ParseTuple(args, ""sss:call"", &arg1, &arg2, &arg3)) {" 14 10 extending/windows,,:initspam,/export:initspam 15 howto/cporting,,:add,"if (!PyArg_ParseTuple(args, ""ii:add_ints"", &one, &two))"16 11 howto/cporting,,:encode,"if (!PyArg_ParseTuple(args, ""O:encode_object"", &myobj))" 17 12 howto/cporting,,:say,"if (!PyArg_ParseTuple(args, ""U:say_hello"", &name))" … … 24 19 howto/curses,,:white,"7:white." 25 20 howto/curses,,:yellow,"They are: 0:black, 1:red, 2:green, 3:yellow, 4:blue, 5:magenta, 6:cyan, and" 21 howto/logging,,:root,WARNING:root:Watch out! 22 howto/logging,,:Watch,WARNING:root:Watch out! 23 howto/logging,,:root,DEBUG:root:This message should go to the log file 24 howto/logging,,:root,INFO:root:So should this 25 howto/logging,,:So,INFO:root:So should this 26 howto/logging,,:root,"WARNING:root:And this, too" 27 howto/logging,,:And,"WARNING:root:And this, too" 28 howto/logging,,:root,INFO:root:Started 29 howto/logging,,:Started,INFO:root:Started 30 howto/logging,,:root,INFO:root:Doing something 31 howto/logging,,:Doing,INFO:root:Doing something 32 howto/logging,,:root,INFO:root:Finished 33 howto/logging,,:Finished,INFO:root:Finished 34 howto/logging,,:root,WARNING:root:Look before you leap! 35 howto/logging,,:Look,WARNING:root:Look before you leap! 36 howto/logging,,:This,DEBUG:This message should appear on the console 37 howto/logging,,:So,INFO:So should this 38 howto/logging,,:And,"WARNING:And this, too" 39 howto/logging,,:logger,severity:logger name:message 40 howto/logging,,:message,severity:logger name:message 41 howto/logging,,:This,DEBUG:root:This message should go to the log file 26 42 howto/regex,,::, 27 43 howto/regex,,:foo,(?:foo) 28 44 howto/urllib2,,:example,"for example ""joe@password:example.com""" 29 howto/webservers,,.. image:,.. image:: http.png30 45 library/audioop,,:ipos,"# factor = audioop.findfactor(in_test[ipos*2:ipos*2+len(out_test)]," 46 library/cookie,,`,!#$%&'*+-.^_`|~ 31 47 library/datetime,,:MM, 32 48 library/datetime,,:SS, … … 42 58 library/doctest,,`,The ``example`` module 43 59 library/doctest,,`,Using ``factorial`` 60 library/exceptions,,:err,err.object[err.start:err.end] 44 61 library/functions,,:step,a[start:stop:step] 45 62 library/functions,,:stop,"a[start:stop, i]" … … 47 64 library/hotshot,,:lineno,"ncalls tottime percall cumtime percall filename:lineno(function)" 48 65 library/httplib,,:port,host:port 49 library/imaplib,,:MM,"""DD-Mmm-YYYY HH:MM:SS +HHMM"""50 library/imaplib,,:SS,"""DD-Mmm-YYYY HH:MM:SS +HHMM"""66 library/imaplib,,:MM,"""DD-Mmm-YYYY HH:MM:SS" 67 library/imaplib,,:SS,"""DD-Mmm-YYYY HH:MM:SS" 51 68 library/itertools,,:stop,elements from seq[start:stop:step] 52 69 library/itertools,,:step,elements from seq[start:stop:step] 53 70 library/linecache,,:sys,"sys:x:3:3:sys:/dev:/bin/sh" 54 library/logging,,:And, 55 library/logging,,:package1, 56 library/logging,,:package2, 57 library/logging,,:root, 58 library/logging,,:This, 59 library/logging,,:port,host:port 71 library/logging.handlers,,:port,host:port 60 72 library/mmap,,:i2,obj[i1:i2] 61 73 library/multiprocessing,,:queue,">>> QueueManager.register('get_queue', callable=lambda:queue)" … … 67 79 library/multiprocessing,,`,# A test of `multiprocessing.Pool` class 68 80 library/multiprocessing,,`,# Add more tasks using `put()` 69 library/multiprocessing,,`,# create server for a `HostManager` object70 library/multiprocessing,,`,# Depends on `multiprocessing` package -- tested with `processing-0.60`71 81 library/multiprocessing,,`,# in the original order then consider using `Pool.map()` or 72 82 library/multiprocessing,,`,# Not sure if we should synchronize access to `socket.accept()` method by … … 75 85 library/multiprocessing,,`,# register the Foo class; make `g()` and `_h()` accessible via proxy 76 86 library/multiprocessing,,`,# register the generator function baz; use `GeneratorProxy` to make proxies 77 library/multiprocessing,,`,`Cluster` is a subclass of `SyncManager` so it allows creation of78 library/multiprocessing,,`,`hostname` gives the name of the host. If hostname is not79 library/multiprocessing,,`,`slots` is used to specify the number of slots for processes on80 87 library/optparse,,:len,"del parser.rargs[:len(value)]" 81 88 library/os.path,,:foo,c:foo 82 library/p arser,,`,"""Make a function that raises an argument to the exponent `exp`."""89 library/pdb,,:lineno,filename:lineno 83 90 library/posix,,`,"CFLAGS=""`getconf LFS_CFLAGS`"" OPT=""-g -O2 $CFLAGS""" 84 91 library/profile,,:lineno,ncalls tottime percall cumtime percall filename:lineno(function) … … 86 93 library/pyexpat,,:elem1,<py:elem1 /> 87 94 library/pyexpat,,:py,"xmlns:py = ""http://www.python.org/ns/"">" 88 library/repr,,`,"return `obj`"89 95 library/smtplib,,:port,"as well as a regular host:port server." 90 96 library/socket,,::,'5aef:2b::8' 91 97 library/sqlite3,,:memory, 92 library/sqlite3,,: age,"select name_last, age from people where name_last=:who and age=:age"93 library/sqlite3,,: who,"select name_last, age from people where name_last=:who and age=:age"98 library/sqlite3,,:who,"cur.execute(""select * from people where name_last=:who and age=:age"", {""who"": who, ""age"": age})" 99 library/sqlite3,,:age,"cur.execute(""select * from people where name_last=:who and age=:age"", {""who"": who, ""age"": age})" 94 100 library/ssl,,:My,"Organization Name (eg, company) [Internet Widgits Pty Ltd]:My Organization, Inc." 95 101 library/ssl,,:My,"Organizational Unit Name (eg, section) []:My Group" … … 100 106 library/ssl,,:US,Country Name (2 letter code) [AU]:US 101 107 library/stdtypes,,:len,s[len(s):len(s)] 102 library/stdtypes,,:len,s[len(s):len(s)]103 library/string,,:end,s[start:end]104 108 library/string,,:end,s[start:end] 105 109 library/subprocess,,`,"output=`mycmd myarg`" … … 123 127 reference/datamodel,,:max, 124 128 reference/expressions,,:index,x[index:index] 125 reference/expressions,,:datum,{key:datum...}126 129 reference/expressions,,`,`expressions...` 127 reference/grammar,,:output,#diagram:output 128 reference/grammar,,:rules,#diagram:rules 129 reference/grammar,,:token,#diagram:token 130 reference/expressions,,`,"""`""" 130 131 reference/grammar,,`,'`' testlist1 '`' 131 132 reference/lexical_analysis,,:fileencoding,# vim:fileencoding=<encoding-name> … … 150 151 using/cmdline,,:module,action:message:category:module:line 151 152 using/cmdline,,:errorhandler,:errorhandler 152 using/windows,162,`,`` this fixes syntax highlighting errors in some editors due to the \\\\ hackery153 using/windows,170,`,``154 153 whatsnew/2.0,418,:len, 155 154 whatsnew/2.3,,::, … … 165 164 whatsnew/2.5,,:step,[start:stop:step] 166 165 whatsnew/2.5,,:stop,[start:stop:step] 166 faq/programming,,:reduce,"print (lambda Ru,Ro,Iu,Io,IM,Sx,Sy:reduce(lambda x,y:x+y,map(lambda y," 167 faq/programming,,:reduce,"Sx=Sx,Sy=Sy:reduce(lambda x,y:x+y,map(lambda x,xc=Ru,yc=yc,Ru=Ru,Ro=Ro," 168 faq/programming,,:chr,">=4.0) or 1+f(xc,yc,x*x-y*y+xc,2.0*x*y+yc,k-1,f):f(xc,yc,x,y,k,f):chr(" 169 faq/programming,,::,for x in sequence[::-1]: 170 library/bisect,,:hi,all(val >= x for val in a[i:hi]) 171 library/bisect,,:hi,all(val > x for val in a[i:hi]) 172 library/socket,,::,"(10, 1, 6, '', ('2001:888:2000:d::a2', 80, 0, 0))]" 173 library/stdtypes,,:end,s[start:end] 174 license,,`,* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 175 license,,`,* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 176 license,,`,"``Software''), to deal in the Software without restriction, including" 177 license,,`,"THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND," 178 whatsnew/2.7,735,:Sunday,'2009:4:Sunday' 179 whatsnew/2.7,862,::,"export PYTHONWARNINGS=all,error:::Cookie:0" 180 whatsnew/2.7,862,:Cookie,"export PYTHONWARNINGS=all,error:::Cookie:0" 181 whatsnew/2.7,,::,>>> urlparse.urlparse('http://[1080::8:800:200C:417A]/foo') 182 whatsnew/2.7,,::,"ParseResult(scheme='http', netloc='[1080::8:800:200C:417A]'," 183 howto/pyporting,75,::,# make sure to use :: Python *and* :: Python :: 3 so 184 howto/pyporting,75,::,"'Programming Language :: Python'," 185 howto/pyporting,75,::,'Programming Language :: Python :: 3' 186 library/urllib2,67,:close,Connection:close -
python/vendor/current/Doc/tools/sphinxext/suspicious.py
r2 r388 42 42 """ 43 43 44 import os, sys 44 import os 45 import re 45 46 import csv 46 import re 47 import sys 48 47 49 from docutils import nodes 48 49 try: 50 from sphinx.builders import Builder 51 except ImportError: 52 from sphinx.builder import Builder 53 50 from sphinx.builders import Builder 54 51 55 52 detect_all = re.compile(ur''' … … 60 57 ''', re.UNICODE | re.VERBOSE).finditer 61 58 59 62 60 class Rule: 63 61 def __init__(self, docname, lineno, issue, line): 64 " A rule for ignoring issues"62 """A rule for ignoring issues""" 65 63 self.docname = docname # document to which this rule applies 66 64 self.lineno = lineno # line number in the original source; … … 69 67 self.issue = issue # the markup fragment that triggered this rule 70 68 self.line = line # text of the container element (single line only) 69 self.used = False 70 71 def __repr__(self): 72 return '{0.docname},,{0.issue},{0.line}'.format(self) 73 74 75 76 class dialect(csv.excel): 77 """Our dialect: uses only linefeed as newline.""" 78 lineterminator = '\n' 71 79 72 80 73 81 class CheckSuspiciousMarkupBuilder(Builder): 74 82 """ 75 Checks for possibly invalid markup that may leak into the output 83 Checks for possibly invalid markup that may leak into the output. 76 84 """ 77 85 name = 'suspicious' … … 82 90 open(self.log_file_name, 'w').close() 83 91 # load database of previously ignored issues 84 self.load_rules(os.path.join(os.path.dirname(__file__), 'susp-ignored.csv')) 92 self.load_rules(os.path.join(os.path.dirname(__file__), 93 'susp-ignored.csv')) 85 94 86 95 def get_outdated_docs(self): … … 91 100 92 101 def prepare_writing(self, docnames): 93 ### PYTHON PROJECT SPECIFIC ### 94 for name in set(docnames): 95 if name.split('/', 1)[0] == 'documenting': 96 docnames.remove(name) 97 ### PYTHON PROJECT SPECIFIC ### 102 pass 98 103 99 104 def write_doc(self, docname, doctree): 100 self.any_issue = False # set when any issue is encountered in this document 105 # set when any issue is encountered in this document 106 self.any_issue = False 101 107 self.docname = docname 102 108 visitor = SuspiciousVisitor(doctree, self) … … 104 110 105 111 def finish(self): 112 unused_rules = [rule for rule in self.rules if not rule.used] 113 if unused_rules: 114 self.warn('Found %s/%s unused rules:' % 115 (len(unused_rules), len(self.rules))) 116 for rule in unused_rules: 117 self.info(repr(rule)) 106 118 return 107 119 … … 111 123 112 124 def is_ignored(self, line, lineno, issue): 113 """Determine whether this issue should be ignored. 114 """ 125 """Determine whether this issue should be ignored.""" 115 126 docname = self.docname 116 127 for rule in self.rules: … … 129 140 abs(rule.lineno - lineno) > 5: continue 130 141 # if it came this far, the rule matched 142 rule.used = True 131 143 return True 132 144 return False … … 145 157 def write_log_entry(self, lineno, issue, text): 146 158 f = open(self.log_file_name, 'ab') 147 writer = csv.writer(f )159 writer = csv.writer(f, dialect) 148 160 writer.writerow([self.docname.encode('utf-8'), 149 lineno, 150 issue.encode('utf-8'), 151 text.strip().encode('utf-8')]) 152 del writer 161 lineno, 162 issue.encode('utf-8'), 163 text.strip().encode('utf-8')]) 153 164 f.close() 154 165 … … 165 176 for i, row in enumerate(csv.reader(f)): 166 177 if len(row) != 4: 167 raise ValueError("wrong format in %s, line %d: %s" % (filename, i+1, row)) 178 raise ValueError( 179 "wrong format in %s, line %d: %s" % (filename, i+1, row)) 168 180 docname, lineno, issue, text = row 169 181 docname = docname.decode('utf-8') … … 179 191 180 192 def get_lineno(node): 181 " Obtain line number information for a node"193 """Obtain line number information for a node.""" 182 194 lineno = None 183 195 while lineno is None and node: … … 204 216 p = text.rfind('\n', 0, index) + 1 205 217 q = text.find('\n', index) 206 if q<0: q = len(text) 218 if q < 0: 219 q = len(text) 207 220 return text[p:q] 208 221 … … 223 236 seen = set() # don't report the same issue more than only once per line 224 237 for match in detect_all(text): 225 #import pdb; pdb.set_trace()226 238 issue = match.group() 227 239 line = extract_line(text, match.start())
Note:
See TracChangeset
for help on using the changeset viewer.