[Python-checkins] r65529 - in doctools/branches/0.4.x: CHANGES sphinx/application.py sphinx/environment.py sphinx/quickstart.py tests/root tests/root/_build tests/root/conf.py tests/test_build.py tests/test_markup.py tests/util.py

georg.brandl python-checkins at python.org
Tue Aug 5 00:19:31 CEST 2008


Author: georg.brandl
Date: Tue Aug  5 00:19:30 2008
New Revision: 65529

Log:
Revert r65499 which was not well thought out. Instead, put
the whole build dir in exclude_trees by default in quickstart.

Also, revisit application cleanup and make it consistently use
less setup time while still trying to leave to traces.


Added:
   doctools/branches/0.4.x/tests/root/_build/   (props changed)
Modified:
   doctools/branches/0.4.x/CHANGES
   doctools/branches/0.4.x/sphinx/application.py
   doctools/branches/0.4.x/sphinx/environment.py
   doctools/branches/0.4.x/sphinx/quickstart.py
   doctools/branches/0.4.x/tests/root/   (props changed)
   doctools/branches/0.4.x/tests/root/conf.py
   doctools/branches/0.4.x/tests/test_build.py
   doctools/branches/0.4.x/tests/test_markup.py
   doctools/branches/0.4.x/tests/util.py

Modified: doctools/branches/0.4.x/CHANGES
==============================================================================
--- doctools/branches/0.4.x/CHANGES	(original)
+++ doctools/branches/0.4.x/CHANGES	Tue Aug  5 00:19:30 2008
@@ -1,9 +1,6 @@
 Release 0.4.3 (in development)
 ==============================
 
-* If output and/or doctree directory are within the source directory,
-  except them from the search for source files.
-
 * Fix encoding handling for literal include files: ``literalinclude``
   now has an ``encoding`` option that defaults to UTF-8.
 

Modified: doctools/branches/0.4.x/sphinx/application.py
==============================================================================
--- doctools/branches/0.4.x/sphinx/application.py	(original)
+++ doctools/branches/0.4.x/sphinx/application.py	Tue Aug  5 00:19:30 2008
@@ -13,7 +13,6 @@
 """
 
 import sys
-from os import path
 
 from docutils import nodes
 from docutils.parsers.rst import directives, roles
@@ -65,10 +64,10 @@
         self.builderclasses = builtin_builders.copy()
         self.builder = None
 
-        self.srcdir = path.abspath(srcdir)
-        self.confdir = path.abspath(confdir)
-        self.outdir = path.abspath(outdir)
-        self.doctreedir = path.abspath(doctreedir)
+        self.srcdir = srcdir
+        self.confdir = confdir
+        self.outdir = outdir
+        self.doctreedir = doctreedir
 
         self._status = status
         self._warning = warning
@@ -89,13 +88,6 @@
         # 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'

Modified: doctools/branches/0.4.x/sphinx/environment.py
==============================================================================
--- doctools/branches/0.4.x/sphinx/environment.py	(original)
+++ doctools/branches/0.4.x/sphinx/environment.py	Tue Aug  5 00:19:30 2008
@@ -575,7 +575,8 @@
             for imgpath in candidates.itervalues():
                 self.dependencies.setdefault(docname, set()).add(imgpath)
                 if not os.access(path.join(self.srcdir, imgpath), os.R_OK):
-                    self.warn(docname, 'Image file not readable: %s' % imgpath, node.line)
+                    self.warn(docname, 'Image file not readable: %s' % imgpath,
+                              node.line)
                 if imgpath in self.images:
                     self.images[imgpath][0].add(docname)
                     continue

Modified: doctools/branches/0.4.x/sphinx/quickstart.py
==============================================================================
--- doctools/branches/0.4.x/sphinx/quickstart.py	(original)
+++ doctools/branches/0.4.x/sphinx/quickstart.py	Tue Aug  5 00:19:30 2008
@@ -80,7 +80,7 @@
 
 # List of directories, relative to source directories, that shouldn't be searched
 # for source files.
-#exclude_dirs = []
+exclude_trees = [%(exclude_trees)s]
 
 # The reST default role (used for this markup: `text`) to use for all documents.
 #default_role = None
@@ -438,8 +438,10 @@
     mkdir_p(srcdir)
     if separate:
         builddir = path.join(d['path'], 'build')
+        d['exclude_trees'] = ''
     else:
         builddir = path.join(srcdir, d['dot'] + 'build')
+        d['exclude_trees'] = repr(d['dot'] + 'build')
     mkdir_p(builddir)
     mkdir_p(path.join(srcdir, d['dot'] + 'templates'))
     mkdir_p(path.join(srcdir, d['dot'] + 'static'))

Modified: doctools/branches/0.4.x/tests/root/conf.py
==============================================================================
--- doctools/branches/0.4.x/tests/root/conf.py	(original)
+++ doctools/branches/0.4.x/tests/root/conf.py	Tue Aug  5 00:19:30 2008
@@ -57,7 +57,6 @@
 
 # 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.

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	Tue Aug  5 00:19:30 2008
@@ -112,6 +112,6 @@
 def test_text(app):
     app.builder.build_all()
 
- at with_testapp(buildername='changes')
+ at with_testapp(buildername='changes', cleanenv=True)
 def test_changes(app):
     app.builder.build_all()

Modified: doctools/branches/0.4.x/tests/test_markup.py
==============================================================================
--- doctools/branches/0.4.x/tests/test_markup.py	(original)
+++ doctools/branches/0.4.x/tests/test_markup.py	Tue Aug  5 00:19:30 2008
@@ -22,7 +22,7 @@
 
 def setup_module():
     global app, settings, parser
-    app = TestApp()
+    app = TestApp(cleanenv=True)
     optparser = frontend.OptionParser(components=(rst.Parser, HTMLWriter, LaTeXWriter))
     settings = optparser.get_default_values()
     settings.env = app.builder.env

Modified: doctools/branches/0.4.x/tests/util.py
==============================================================================
--- doctools/branches/0.4.x/tests/util.py	(original)
+++ doctools/branches/0.4.x/tests/util.py	Tue Aug  5 00:19:30 2008
@@ -89,32 +89,34 @@
 
     def __init__(self, srcdir=None, confdir=None, outdir=None, doctreedir=None,
                  buildername='html', confoverrides=None, status=None, warning=None,
-                 freshenv=None, confname='conf.py'):
+                 freshenv=None, confname='conf.py', cleanenv=False):
 
         application.CONFIG_FILENAME = confname
 
+        self.cleanup_trees = []
+
         if srcdir is None:
             srcdir = test_root
         if srcdir == '(temp)':
-            tempdir = path(tempfile.mkdtemp()) / 'root'
-            test_root.copytree(tempdir)
-            srcdir = tempdir
+            tempdir = path(tempfile.mkdtemp())
+            self.cleanup_trees.append(tempdir)
+            temproot = tempdir / 'root'
+            test_root.copytree(temproot)
+            srcdir = temproot
         else:
             srcdir = path(srcdir)
         self.builddir = srcdir.joinpath('_build')
-        if not self.builddir.isdir():
-            self.builddir.makedirs()
-            self.made_builddir = True
-        else:
-            self.made_builddir = False
         if confdir is None:
             confdir = srcdir
         if outdir is None:
             outdir = srcdir.joinpath(self.builddir, buildername)
             if not outdir.isdir():
                 outdir.makedirs()
+            self.cleanup_trees.insert(0, outdir)
         if doctreedir is None:
             doctreedir = srcdir.joinpath(srcdir, self.builddir, 'doctrees')
+            if cleanenv:
+                self.cleanup_trees.insert(0, doctreedir)
         if confoverrides is None:
             confoverrides = {}
         if status is None:
@@ -122,17 +124,14 @@
         if warning is None:
             warning = ListOutput('stderr')
         if freshenv is None:
-            freshenv = True
+            freshenv = False
 
         application.Sphinx.__init__(self, srcdir, confdir, outdir, doctreedir,
                                     buildername, confoverrides, status, warning,
                                     freshenv)
 
-    def cleanup(self):
-        trees = [self.outdir, self.doctreedir]
-        if self.made_builddir:
-            trees.append(self.builddir)
-        for tree in trees:
+    def cleanup(self, doctrees=False):
+        for tree in self.cleanup_trees:
             shutil.rmtree(tree, True)
 
 


More information about the Python-checkins mailing list