diff --git a/sphinx/latexwriter.py b/sphinx/latexwriter.py index d35252b83..a24518929 100644 --- a/sphinx/latexwriter.py +++ b/sphinx/latexwriter.py @@ -97,6 +97,8 @@ class LaTeXTranslator(nodes.NodeVisitor): 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 @@ class LaTeXTranslator(nodes.NodeVisitor): 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 diff --git a/tests/root/markup.txt b/tests/root/markup.txt index 98a98fc2e..53812ca77 100644 --- a/tests/root/markup.txt +++ b/tests/root/markup.txt @@ -18,14 +18,14 @@ Admonitions Warning text. -.. tip: +.. tip:: Tip text. Tables ------ -.. tabularcolumns:: |L|L|R| +.. tabularcolumns:: |L|p{5cm}|R| +----+----------------+----+ | 1 | * Block elems | x | @@ -42,7 +42,7 @@ Version markup Some funny **stuff**. .. versionchanged:: 0.5 - Even more funny stuff. [#]_ + Even more funny stuff. .. deprecated:: 0.4 Boring stuff. @@ -51,6 +51,8 @@ Version markup Misc stuff ---------- +Stuff [#]_ + .. seealso:: `Google `_ diff --git a/tests/test_build.py b/tests/test_build.py index 5ce482733..234c1d5b7 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -13,11 +13,13 @@ import os 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 @@ def test_html(app): @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 @@ def test_latex(app): '\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