diff --git a/sphinx/__init__.py b/sphinx/__init__.py index 33b917c41..592270038 100644 --- a/sphinx/__init__.py +++ b/sphinx/__init__.py @@ -98,7 +98,7 @@ def main(argv=sys.argv): return 1 all_files = True elif opt == '-d': - doctreedir = val + doctreedir = path.abspath(val) elif opt == '-c': confdir = path.abspath(val) if not path.isfile(path.join(confdir, 'conf.py')): diff --git a/sphinx/application.py b/sphinx/application.py index e7a3858a1..12fca8ba6 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -13,6 +13,7 @@ """ import sys +from os import path from docutils import nodes from docutils.parsers.rst import directives, roles @@ -66,10 +67,10 @@ class Sphinx(object): self.builderclasses = builtin_builders.copy() self.builder = None - self.srcdir = srcdir - self.confdir = confdir - self.outdir = outdir - self.doctreedir = doctreedir + self.srcdir = path.abspath(srcdir) + self.confdir = path.abspath(confdir) + self.outdir = path.abspath(outdir) + self.doctreedir = path.abspath(doctreedir) self._status = status self._warning = warning @@ -90,6 +91,13 @@ class Sphinx(object): # now that we know all config values, collect them from conf.py self.config.init_values() + # if the output and/or doctree dirs are within the source dir, except + # them from being searched for source files + if self.outdir.startswith(self.srcdir): + self.config.exclude_trees += [self.outdir[len(self.srcdir)+1:]] + if self.doctreedir.startswith(self.srcdir): + self.config.exclude_trees += [self.doctreedir[len(self.srcdir)+1:]] + if buildername is None: print >>status, 'No builder selected, using default: html' buildername = 'html' diff --git a/sphinx/builder.py b/sphinx/builder.py index 4e4f0bf9f..0af8e8cd3 100644 --- a/sphinx/builder.py +++ b/sphinx/builder.py @@ -1030,6 +1030,9 @@ class ChangesBuilder(Builder): libchanges = {} apichanges = [] otherchanges = {} + if version not in self.env.versionchanges: + self.info(bold('no changes in this version.')) + return self.info(bold('writing summary file...')) for type, docname, lineno, module, descname, content in \ self.env.versionchanges[version]: diff --git a/sphinx/textwriter.py b/sphinx/textwriter.py index 90f6265c1..326042307 100644 --- a/sphinx/textwriter.py +++ b/sphinx/textwriter.py @@ -350,6 +350,7 @@ class TextTranslator(nodes.NodeVisitor): def visit_image(self, node): self.add_text('[image]') + raise nodes.SkipNode def visit_transition(self, node): indent = sum(self.stateindent) diff --git a/tests/root/conf.py b/tests/root/conf.py index ff29ae51e..5bd659efb 100644 --- a/tests/root/conf.py +++ b/tests/root/conf.py @@ -58,6 +58,7 @@ today_fmt = '%B %d, %Y' # List of directories, relative to source directories, that shouldn't be searched # for source files. #exclude_dirs = [] +exclude_trees = ['_build'] # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True diff --git a/tests/test_build.py b/tests/test_build.py index 9c90f0191..9046bc898 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -10,11 +10,12 @@ """ import os +import difflib import htmlentitydefs from StringIO import StringIO -from etree13 import ElementTree as ET from util import * +from etree13 import ElementTree as ET from sphinx.builder import StandaloneHTMLBuilder, LaTeXBuilder @@ -66,14 +67,17 @@ class NslessParser(ET.XMLParser): def test_html(app): app.builder.build_all() html_warnings = html_warnfile.getvalue().replace(os.sep, '/') - assert html_warnings == HTML_WARNINGS % {'root': app.srcdir} + html_warnings_exp = HTML_WARNINGS % {'root': app.srcdir} + assert html_warnings == html_warnings_exp, 'Warnings don\'t match:\n' + \ + '\n'.join(difflib.ndiff(html_warnings_exp.splitlines(), + html_warnings.splitlines())) if not ET: return for fname, paths in HTML_XPATH.iteritems(): parser = NslessParser() parser.entity.update(htmlentitydefs.entitydefs) - etree = ET.parse(app.outdir / fname, parser) + etree = ET.parse(os.path.join(app.outdir, fname), parser) for path, text in paths.iteritems(): nodes = list(etree.findall(path)) assert nodes != [] @@ -92,4 +96,22 @@ def test_html(app): def test_latex(app): app.builder.build_all() latex_warnings = latex_warnfile.getvalue().replace(os.sep, '/') - assert latex_warnings == LATEX_WARNINGS % {'root': app.srcdir} + latex_warnings_exp = LATEX_WARNINGS % {'root': app.srcdir} + assert latex_warnings == latex_warnings_exp, 'Warnings don\'t match:\n' + \ + '\n'.join(difflib.ndiff(latex_warnings_exp.splitlines(), + latex_warnings.splitlines())) + + +# just let the remaining ones run for now + +@with_testapp(buildername='linkcheck') +def test_linkcheck(app): + app.builder.build_all() + +@with_testapp(buildername='text') +def test_text(app): + app.builder.build_all() + +@with_testapp(buildername='changes') +def test_changes(app): + app.builder.build_all() diff --git a/tests/util.py b/tests/util.py index 6badf8a50..ba53c43c7 100644 --- a/tests/util.py +++ b/tests/util.py @@ -135,10 +135,10 @@ class TestApp(application.Sphinx): def cleanup(self): trees = [self.outdir, self.doctreedir] - #f self.made_builddir: - # trees.append(self.builddir) - #for tree in trees: - # shutil.rmtree(tree, True) + if self.made_builddir: + trees.append(self.builddir) + for tree in trees: + shutil.rmtree(tree, True) def with_testapp(*args, **kwargs):