• R/O
  • SSH
  • HTTPS

pythonjp: Commit


Commit MetaInfo

Revision717 (tree)
Time2010-12-06 21:55:49
Authoromoikane

Log Message

最新の sphinxext を移植.

Change Summary

Incremental Difference

--- Doc/trunk/tools/sphinxext/pyspecific.py (revision 716)
+++ Doc/trunk/tools/sphinxext/pyspecific.py (revision 717)
@@ -5,7 +5,7 @@
55
66 Sphinx extension with Python doc-specific markup.
77
8- :copyright: 2008 by Georg Brandl.
8+ :copyright: 2008, 2009 by Georg Brandl.
99 :license: Python license.
1010 """
1111
@@ -20,7 +20,22 @@
2020 Body.enum.converters['lowerroman'] = \
2121 Body.enum.converters['upperroman'] = lambda x: None
2222
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)
2332
33+from sphinx.writers.html import HTMLTranslator
34+from sphinx.locale import versionlabels
35+HTMLTranslator.visit_versionmodified = new_visit_versionmodified
36+
37+# Support for marking up and linking to bugs.python.org issues
38+
2439 def issue_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
2540 issue = utils.unescape(text)
2641 text = 'issue ' + issue
@@ -28,6 +43,34 @@
2843 return [refnode], []
2944
3045
46+# Support for marking up implementation details
47+
48+from sphinx.util.compat import Directive
49+
50+class ImplementationDetail(Directive):
51+
52+ has_content = True
53+ required_arguments = 0
54+ optional_arguments = 1
55+ final_argument_whitespace = True
56+
57+ def run(self):
58+ pnode = nodes.compound(classes=['impl-detail'])
59+ content = self.content
60+ add_text = nodes.strong('CPython implementation detail:',
61+ 'CPython implementation detail:')
62+ if self.arguments:
63+ n, m = self.state.inline_text(self.arguments[0], self.lineno)
64+ pnode.append(nodes.paragraph('', '', *(n + m)))
65+ self.state.nested_parse(content, self.content_offset, pnode)
66+ if pnode.children and isinstance(pnode[0], nodes.paragraph):
67+ pnode[0].insert(0, add_text)
68+ pnode[0].insert(1, nodes.Text(' '))
69+ else:
70+ pnode.insert(0, nodes.paragraph('', '', add_text))
71+ return [pnode]
72+
73+
3174 # Support for building "topic help" for pydoc
3275
3376 pydoc_topic_labels = [
@@ -59,7 +102,11 @@
59102 try:
60103 from sphinx.builders import Builder
61104 except ImportError:
105+ # using Sphinx < 0.6, which has a different package layout
62106 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']
63110
64111 try:
65112 from sphinx.writers.text import TextWriter
@@ -101,10 +148,12 @@
101148 finally:
102149 f.close()
103150
151+
104152 # Support for checking for suspicious markup
105153
106154 import suspicious
107155
156+
108157 # Support for documenting Opcodes
109158
110159 import re
@@ -127,7 +176,9 @@
127176
128177 def setup(app):
129178 app.add_role('issue', issue_role)
179+ app.add_directive('impl-detail', ImplementationDetail)
130180 app.add_builder(PydocTopicsBuilder)
131181 app.add_builder(suspicious.CheckSuspiciousMarkupBuilder)
132182 app.add_description_unit('opcode', 'opcode', '%s (opcode)',
133183 parse_opcode_signature)
184+ app.add_description_unit('2to3fixer', '2to3fixer', '%s (2to3 fixer)')
--- Doc/trunk/tools/sphinxext/suspicious.py (revision 716)
+++ Doc/trunk/tools/sphinxext/suspicious.py (revision 717)
@@ -164,7 +164,7 @@
164164 except IOError: return
165165 for i, row in enumerate(csv.reader(f)):
166166 if len(row) != 4:
167- raise ValueError, "wrong format in %s, line %d: %s" % (filename, i+1, row)
167+ raise ValueError("wrong format in %s, line %d: %s" % (filename, i+1, row))
168168 docname, lineno, issue, text = row
169169 docname = docname.decode('utf-8')
170170 if lineno: lineno = int(lineno)
Show on old repository browser