summaryrefslogtreecommitdiffstats
path: root/Doc/tools
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2012-10-10 14:49:18 (GMT)
committerGeorg Brandl <georg@python.org>2012-10-10 14:49:18 (GMT)
commit42ac3c91e75fc3b44c3d5e3ab30db6d022f3f749 (patch)
tree9528bddbca8c78c76288fe0d10723e9fbbd4a6dc /Doc/tools
parent6428d787aaa5493602a333facf40f5e0d68e364e (diff)
parenta36a1ee4cfbff5ca4029b61c18a921ad1c45fc19 (diff)
downloadcpython-42ac3c91e75fc3b44c3d5e3ab30db6d022f3f749.zip
cpython-42ac3c91e75fc3b44c3d5e3ab30db6d022f3f749.tar.gz
cpython-42ac3c91e75fc3b44c3d5e3ab30db6d022f3f749.tar.bz2
merge 3.3
Diffstat (limited to 'Doc/tools')
-rw-r--r--Doc/tools/sphinxext/pyspecific.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/Doc/tools/sphinxext/pyspecific.py b/Doc/tools/sphinxext/pyspecific.py
index 810830d..df6e48a 100644
--- a/Doc/tools/sphinxext/pyspecific.py
+++ b/Doc/tools/sphinxext/pyspecific.py
@@ -33,9 +33,38 @@ def new_visit_versionmodified(self, node):
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
+# monkey-patch HTML and LaTeX translators to keep doctest blocks in the
+# doctest docs themselves
+orig_visit_literal_block = HTMLTranslator.visit_literal_block
+def new_visit_literal_block(self, node):
+ meta = self.builder.env.metadata[self.builder.current_docname]
+ old_trim_doctest_flags = self.highlighter.trim_doctest_flags
+ if 'keepdoctest' in meta:
+ self.highlighter.trim_doctest_flags = False
+ try:
+ orig_visit_literal_block(self, node)
+ finally:
+ self.highlighter.trim_doctest_flags = old_trim_doctest_flags
+
+HTMLTranslator.visit_literal_block = new_visit_literal_block
+
+orig_depart_literal_block = LaTeXTranslator.depart_literal_block
+def new_depart_literal_block(self, node):
+ meta = self.builder.env.metadata[self.curfilestack[-1]]
+ old_trim_doctest_flags = self.highlighter.trim_doctest_flags
+ if 'keepdoctest' in meta:
+ self.highlighter.trim_doctest_flags = False
+ try:
+ orig_depart_literal_block(self, node)
+ finally:
+ self.highlighter.trim_doctest_flags = old_trim_doctest_flags
+
+LaTeXTranslator.depart_literal_block = new_depart_literal_block
# Support for marking up and linking to bugs.python.org issues