Kaydet (Commit) e9bd31f9 authored tarafından Georg Brandl's avatar Georg Brandl

merge with 3.3

...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
Sphinx extension with Python doc-specific markup. 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. :license: Python license.
""" """
...@@ -13,7 +13,12 @@ ISSUE_URI = 'http://bugs.python.org/issue%s' ...@@ -13,7 +13,12 @@ ISSUE_URI = 'http://bugs.python.org/issue%s'
SOURCE_URI = 'http://hg.python.org/cpython/file/default/%s' SOURCE_URI = 'http://hg.python.org/cpython/file/default/%s'
from docutils import nodes, utils from docutils import nodes, utils
import sphinx
from sphinx.util.nodes import split_explicit_title 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 # monkey-patch reST parser to disable alphabetic and roman enumerated lists
from docutils.parsers.rst.states import Body from docutils.parsers.rst.states import Body
...@@ -22,21 +27,17 @@ Body.enum.converters['loweralpha'] = \ ...@@ -22,21 +27,17 @@ Body.enum.converters['loweralpha'] = \
Body.enum.converters['lowerroman'] = \ Body.enum.converters['lowerroman'] = \
Body.enum.converters['upperroman'] = lambda x: None Body.enum.converters['upperroman'] = lambda x: None
# monkey-patch HTML translator to give versionmodified paragraphs a class if sphinx.__version__[:3] < '1.2':
def new_visit_versionmodified(self, node): # monkey-patch HTML translator to give versionmodified paragraphs a class
self.body.append(self.starttag(node, 'p', CLASS=node['type'])) def new_visit_versionmodified(self, node):
text = versionlabels[node['type']] % node['version'] self.body.append(self.starttag(node, 'p', CLASS=node['type']))
if len(node): text = versionlabels[node['type']] % node['version']
text += ':' if len(node):
else: text += ':'
text += '.' else:
self.body.append('<span class="versionmodified">%s</span> ' % text) text += '.'
self.body.append('<span class="versionmodified">%s</span> ' % text)
from sphinx.writers.html import HTMLTranslator HTMLTranslator.visit_versionmodified = new_visit_versionmodified
from sphinx.writers.latex import LaTeXTranslator
from sphinx.locale import versionlabels
HTMLTranslator.visit_versionmodified = new_visit_versionmodified
HTMLTranslator.visit_versionmodified = new_visit_versionmodified
# monkey-patch HTML and LaTeX translators to keep doctest blocks in the # monkey-patch HTML and LaTeX translators to keep doctest blocks in the
# doctest docs themselves # doctest docs themselves
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment