[Python-checkins] r56846 - doctools/trunk/sphinx/__init__.py doctools/trunk/sphinx/builder.py

georg.brandl python-checkins at python.org
Thu Aug 9 11:47:25 CEST 2007


Author: georg.brandl
Date: Thu Aug  9 11:47:24 2007
New Revision: 56846

Modified:
   doctools/trunk/sphinx/__init__.py
   doctools/trunk/sphinx/builder.py
Log:
Add an explicit doctreedir option.


Modified: doctools/trunk/sphinx/__init__.py
==============================================================================
--- doctools/trunk/sphinx/__init__.py	(original)
+++ doctools/trunk/sphinx/__init__.py	Thu Aug  9 11:47:24 2007
@@ -27,6 +27,7 @@
 usage: %s [options] sourcedir outdir [filenames...]"
 options: -b <builder> -- builder to use (one of %s)
          -a -- write all files; default is to only write new and changed files
+         -d <path> -- path for the cached doctree files (default outdir/.doctrees)
          -O <option[=value]> -- give option to to the builder (-O help for list)
          -D <setting=value> -- override a setting in sourcedir/conf.py
          -N -- do not do colored output
@@ -38,7 +39,7 @@
 
 def main(argv):
     try:
-        opts, args = getopt.getopt(argv[1:], 'ab:O:D:N')
+        opts, args = getopt.getopt(argv[1:], 'ab:d:O:D:N')
         srcdirname = path.abspath(args[0])
         if not path.isdir(srcdirname):
             print >>sys.stderr, 'Error: Cannot find source directory.'
@@ -67,6 +68,7 @@
     opt_help = False
     options = {}
     confoverrides = {}
+    doctreedir = path.join(outdirname, '.doctrees')
     for opt, val in opts:
         if opt == '-b':
             if val not in builders:
@@ -78,6 +80,8 @@
                 usage(argv, 'Cannot combine -a option and filenames.')
                 return 1
             all_files = True
+        elif opt == '-d':
+            doctreedir = val
         elif opt == '-O':
             if val == 'help':
                 opt_help = True
@@ -115,7 +119,7 @@
             print ' * %s: %s' % (optname, description)
         return 0
 
-    builderobj = builderobj(srcdirname, outdirname, options,
+    builderobj = builderobj(srcdirname, outdirname, doctreedir, options,
                             status_stream=sys.stdout,
                             warning_stream=sys.stderr,
                             confoverrides=confoverrides)

Modified: doctools/trunk/sphinx/builder.py
==============================================================================
--- doctools/trunk/sphinx/builder.py	(original)
+++ doctools/trunk/sphinx/builder.py	Thu Aug  9 11:47:24 2007
@@ -76,13 +76,14 @@
         'freshenv': 'Don\'t use a pickled environment',
     }
 
-    def __init__(self, srcdirname, outdirname, options, env=None,
-                 status_stream=None, warning_stream=None,
-                 confoverrides=None):
+    def __init__(self, srcdirname, outdirname, doctreedirname,
+                 options, confoverrides=None, env=None,
+                 status_stream=None, warning_stream=None):
         self.srcdir = srcdirname
         self.outdir = outdirname
-        if not path.isdir(path.join(outdirname, '.doctrees')):
-            os.mkdir(path.join(outdirname, '.doctrees'))
+        self.doctreedir = doctreedirname
+        if not path.isdir(doctreedirname):
+            os.mkdir(doctreedirname)
 
         self.options = attrdict(options)
         self.validate_options()
@@ -104,9 +105,10 @@
             try:
                 version, release = get_version_info(srcdirname)
             except (IOError, OSError):
-                print >>warning_stream, 'WARNING: Can\'t get version info from ' \
-                      'Include/patchlevel.h, using version of this interpreter.'
                 version, release = get_sys_version_info()
+                print >>warning_stream, 'WARNING: Can\'t get version info from ' \
+                      'Include/patchlevel.h, using version of this ' \
+                      'interpreter (%s).' % release
             if self.config['version'] == 'auto':
                 self.config['version'] = version
             if self.config['release'] == 'auto':
@@ -163,15 +165,13 @@
             try:
                 self.msg('trying to load pickled env...', nonl=True)
                 self.env = BuildEnvironment.frompickle(
-                    path.join(self.outdir, ENV_PICKLE_FILENAME))
+                    path.join(self.doctreedir, ENV_PICKLE_FILENAME))
                 self.msg('done', nobold=True)
             except Exception, err:
                 self.msg('failed: %s' % err, nobold=True)
-                self.env = BuildEnvironment(self.srcdir,
-                                            path.join(self.outdir, '.doctrees'))
+                self.env = BuildEnvironment(self.srcdir, self.doctreedir)
         else:
-            self.env = BuildEnvironment(self.srcdir,
-                                        path.join(self.outdir, '.doctrees'))
+            self.env = BuildEnvironment(self.srcdir, self.doctreedir)
 
     def build_all(self):
         """Build all source files."""
@@ -214,7 +214,7 @@
 
         # save the environment
         self.msg('pickling the env...', nonl=True)
-        self.env.topickle(path.join(self.outdir, ENV_PICKLE_FILENAME))
+        self.env.topickle(path.join(self.doctreedir, ENV_PICKLE_FILENAME))
         self.msg('done', nobold=True)
 
         # global actions


More information about the Python-checkins mailing list