diff options
author | Georg Brandl <georg@python.org> | 2013-10-12 18:53:53 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2013-10-12 18:53:53 (GMT) |
commit | e9bd31f98f4dcacb9d1da3f68a57359eb262e833 (patch) | |
tree | 85abe655cc73831a8b53f257f0e9bbf68d4ca127 /Doc/tools | |
parent | 5a5d73a395b99717e8c5ce04378349abf1f4662e (diff) | |
parent | 239990daec1b4789c407ed022b5993f61d6e158e (diff) | |
download | cpython-e9bd31f98f4dcacb9d1da3f68a57359eb262e833.zip cpython-e9bd31f98f4dcacb9d1da3f68a57359eb262e833.tar.gz cpython-e9bd31f98f4dcacb9d1da3f68a57359eb262e833.tar.bz2 |
merge with 3.3
Diffstat (limited to 'Doc/tools')
-rw-r--r-- | Doc/tools/sphinxext/pyspecific.py | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/Doc/tools/sphinxext/pyspecific.py b/Doc/tools/sphinxext/pyspecific.py index df6e48a..2b5de14 100644 --- a/Doc/tools/sphinxext/pyspecific.py +++ b/Doc/tools/sphinxext/pyspecific.py @@ -5,7 +5,7 @@ Sphinx extension with Python doc-specific markup. - :copyright: 2008, 2009, 2010, 2011, 2012 by Georg Brandl. + :copyright: 2008-2013 by Georg Brandl. :license: Python license. """ @@ -13,7 +13,12 @@ ISSUE_URI = 'http://bugs.python.org/issue%s' SOURCE_URI = 'http://hg.python.org/cpython/file/default/%s' from docutils import nodes, utils + +import sphinx from sphinx.util.nodes import split_explicit_title +from sphinx.writers.html import HTMLTranslator +from sphinx.writers.latex import LaTeXTranslator +from sphinx.locale import versionlabels # monkey-patch reST parser to disable alphabetic and roman enumerated lists from docutils.parsers.rst.states import Body @@ -22,21 +27,17 @@ Body.enum.converters['loweralpha'] = \ Body.enum.converters['lowerroman'] = \ Body.enum.converters['upperroman'] = lambda x: None -# monkey-patch HTML translator to give versionmodified paragraphs a class -def new_visit_versionmodified(self, node): - self.body.append(self.starttag(node, 'p', CLASS=node['type'])) - text = versionlabels[node['type']] % node['version'] - if len(node): - text += ':' - else: - text += '.' - self.body.append('<span class="versionmodified">%s</span> ' % text) - -from sphinx.writers.html import HTMLTranslator -from sphinx.writers.latex import LaTeXTranslator -from sphinx.locale import versionlabels -HTMLTranslator.visit_versionmodified = new_visit_versionmodified -HTMLTranslator.visit_versionmodified = new_visit_versionmodified +if sphinx.__version__[:3] < '1.2': + # monkey-patch HTML translator to give versionmodified paragraphs a class + def new_visit_versionmodified(self, node): + self.body.append(self.starttag(node, 'p', CLASS=node['type'])) + text = versionlabels[node['type']] % node['version'] + if len(node): + text += ':' + else: + text += '.' + self.body.append('<span class="versionmodified">%s</span> ' % text) + HTMLTranslator.visit_versionmodified = new_visit_versionmodified # monkey-patch HTML and LaTeX translators to keep doctest blocks in the # doctest docs themselves |