[Python-checkins] r65556 - in doctools/branches/0.4.x: sphinx/latexwriter.py tests/root/markup.txt tests/test_build.py

georg.brandl python-checkins at python.org
Wed Aug 6 17:12:43 CEST 2008


Author: georg.brandl
Date: Wed Aug  6 17:12:43 2008
New Revision: 65556

Log:
Run latex over the latex builder's output.


Modified:
   doctools/branches/0.4.x/sphinx/latexwriter.py
   doctools/branches/0.4.x/tests/root/markup.txt
   doctools/branches/0.4.x/tests/test_build.py

Modified: doctools/branches/0.4.x/sphinx/latexwriter.py
==============================================================================
--- doctools/branches/0.4.x/sphinx/latexwriter.py	(original)
+++ doctools/branches/0.4.x/sphinx/latexwriter.py	Wed Aug  6 17:12:43 2008
@@ -97,6 +97,8 @@
     sectionnames = ["part", "chapter", "section", "subsection",
                     "subsubsection", "paragraph", "subparagraph"]
 
+    ignore_missing_images = False
+
     def __init__(self, document, builder):
         nodes.NodeVisitor.__init__(self, document)
         self.builder = builder
@@ -665,6 +667,9 @@
         if node['uri'] in self.builder.images:
             uri = self.builder.images[node['uri']]
         else:
+            # missing image!
+            if self.ignore_missing_images:
+                return
             uri = node['uri']
         if uri.find('://') != -1:
             # ignore remote images

Modified: doctools/branches/0.4.x/tests/root/markup.txt
==============================================================================
--- doctools/branches/0.4.x/tests/root/markup.txt	(original)
+++ doctools/branches/0.4.x/tests/root/markup.txt	Wed Aug  6 17:12:43 2008
@@ -18,14 +18,14 @@
 
    Warning text.
 
-.. tip:
+.. tip::
    Tip text.
 
 
 Tables
 ------
 
-.. tabularcolumns:: |L|L|R|
+.. tabularcolumns:: |L|p{5cm}|R|
 
 +----+----------------+----+
 | 1  | * Block elems  |  x |
@@ -42,7 +42,7 @@
    Some funny **stuff**.
 
 .. versionchanged:: 0.5
-   Even more funny stuff. [#]_
+   Even more funny stuff.
 
 .. deprecated:: 0.4
    Boring stuff.
@@ -51,6 +51,8 @@
 Misc stuff
 ----------
 
+Stuff [#]_
+
 .. seealso::
 
    `Google <http://www.google.com>`_

Modified: doctools/branches/0.4.x/tests/test_build.py
==============================================================================
--- doctools/branches/0.4.x/tests/test_build.py	(original)
+++ doctools/branches/0.4.x/tests/test_build.py	Wed Aug  6 17:12:43 2008
@@ -13,11 +13,13 @@
 import difflib
 import htmlentitydefs
 from StringIO import StringIO
+from subprocess import Popen, PIPE
 
 from util import *
 from etree13 import ElementTree as ET
 
 from sphinx.builder import StandaloneHTMLBuilder, LaTeXBuilder
+from sphinx.latexwriter import LaTeXTranslator
 
 
 html_warnfile = StringIO()
@@ -94,6 +96,7 @@
 
 @with_testapp(buildername='latex', warning=latex_warnfile)
 def test_latex(app):
+    LaTeXTranslator.ignore_missing_images = True
     app.builder.build_all()
     latex_warnings = latex_warnfile.getvalue().replace(os.sep, '/')
     latex_warnings_exp = LATEX_WARNINGS % {'root': app.srcdir}
@@ -101,6 +104,23 @@
            '\n'.join(difflib.ndiff(latex_warnings_exp.splitlines(),
                                    latex_warnings.splitlines()))
 
+    # now, try to run latex over it
+    cwd = os.getcwd()
+    os.chdir(app.outdir)
+    try:
+        try:
+            p = Popen(['pdflatex', '--interaction=nonstopmode', 'SphinxTests.tex'],
+                      stdout=PIPE, stderr=PIPE)
+        except OSError, err:
+            pass  # most likely pdflatex was not found
+        else:
+            stdout, stderr = p.communicate()
+            if p.returncode != 0:
+                print stdout
+                del app.cleanup_trees[:]
+                assert False, 'latex exited with error'
+    finally:
+        os.chdir(cwd)
 
 # just let the remaining ones run for now
 


More information about the Python-checkins mailing list