[Python-checkins] cpython (3.4): Closes #21431: make docs depend on Sphinx 1.2 and fix pydoc-topics builder to

georg.brandl python-checkins at python.org
Mon Sep 22 21:23:31 CEST 2014


https://hg.python.org/cpython/rev/d71c351a6a0f
changeset:   92523:d71c351a6a0f
branch:      3.4
user:        Georg Brandl <georg at python.org>
date:        Mon Sep 22 21:18:24 2014 +0200
summary:
  Closes #21431: make docs depend on Sphinx 1.2 and fix pydoc-topics builder to
return Unicode strings on Python 3.

files:
  Doc/conf.py                       |   2 +-
  Doc/tools/sphinxext/pyspecific.py |  32 +++---------------
  2 files changed, 7 insertions(+), 27 deletions(-)


diff --git a/Doc/conf.py b/Doc/conf.py
--- a/Doc/conf.py
+++ b/Doc/conf.py
@@ -61,7 +61,7 @@
 # By default, highlight as Python 3.
 highlight_language = 'python3'
 
-needs_sphinx = '1.1'
+needs_sphinx = '1.2'
 
 
 # Options for HTML output
diff --git a/Doc/tools/sphinxext/pyspecific.py b/Doc/tools/sphinxext/pyspecific.py
--- a/Doc/tools/sphinxext/pyspecific.py
+++ b/Doc/tools/sphinxext/pyspecific.py
@@ -14,12 +14,10 @@
 
 from docutils import nodes, utils
 
-import sphinx
 from sphinx.util.nodes import split_explicit_title
 from sphinx.util.compat import Directive
 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
@@ -28,20 +26,6 @@
     Body.enum.converters['lowerroman'] = \
     Body.enum.converters['upperroman'] = lambda x: None
 
-SPHINX11 = sphinx.__version__[:3] < '1.2'
-
-if SPHINX11:
-    # 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
 orig_visit_literal_block = HTMLTranslator.visit_literal_block
@@ -174,10 +158,9 @@
                 content.line = node[0].line
                 content += node[0].children
                 node[0].replace_self(nodes.paragraph('', '', content))
-            if not SPHINX11:
                 node[0].insert(0, nodes.inline('', '%s: ' % text,
                                                classes=['versionmodified']))
-        elif not SPHINX11:
+        else:
             para = nodes.paragraph('', '',
                 nodes.inline('', '%s.' % text, classes=['versionmodified']))
             if len(node):
@@ -188,9 +171,6 @@
         env.note_versionchange('deprecated', version[0], node, self.lineno)
         return [node] + messages
 
-# for Sphinx < 1.2
-versionlabels['deprecated-removed'] = DeprecatedRemoved._label
-
 
 # Support for including Misc/NEWS
 
@@ -289,14 +269,14 @@
             document.append(doctree.ids[labelid])
             destination = StringOutput(encoding='utf-8')
             writer.write(document, destination)
-            self.topics[label] = writer.output.encode('utf-8')
+            self.topics[label] = writer.output
 
     def finish(self):
-        f = open(path.join(self.outdir, 'topics.py'), 'w')
+        f = open(path.join(self.outdir, 'topics.py'), 'wb')
         try:
-            f.write('# -*- coding: utf-8 -*-\n')
-            f.write('# Autogenerated by Sphinx on %s\n' % asctime())
-            f.write('topics = ' + pformat(self.topics) + '\n')
+            f.write('# -*- coding: utf-8 -*-\n'.encode('utf-8'))
+            f.write(('# Autogenerated by Sphinx on %s\n' % asctime()).encode('utf-8'))
+            f.write(('topics = ' + pformat(self.topics) + '\n').encode('utf-8'))
         finally:
             f.close()
 

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list