Anonymous avatar Anonymous committed 668fa24

Add an explicit doctreedir option.

Comments (0)

Files changed (2)


 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/
          -N -- do not do colored output
 def main(argv):
-        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.'
     opt_help = False
     options = {}
     confoverrides = {}
+    doctreedir = path.join(outdirname, '.doctrees')
     for opt, val in opts:
         if opt == '-b':
             if val not in builders:
                 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
             print ' * %s: %s' % (optname, description)
         return 0
-    builderobj = builderobj(srcdirname, outdirname, options,
+    builderobj = builderobj(srcdirname, outdirname, doctreedir, options,


         '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)
                 version, release = get_version_info(srcdirname)
             except (IOError, OSError):
+                version, release = get_sys_version_info()
                 print >>warning_stream, 'WARNING: Can\'t get version info from ' \
-                      'Include/patchlevel.h, using version of this interpreter.'
-                version, release = get_sys_version_info()
+                      'Include/patchlevel.h, using version of this ' \
+                      'interpreter (%s).' % release
             if self.config['version'] == 'auto':
                 self.config['version'] = version
             if self.config['release'] == 'auto':
                 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)
-            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."""
         # 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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.