Commits

Georg Brandl  committed 3fc912a

Introduce a "-j" flag for parallel build.

  • Participants
  • Parent commits 7cd324a

Comments (0)

Files changed (2)

File sphinx/application.py

 
     def __init__(self, srcdir, confdir, outdir, doctreedir, buildername,
                  confoverrides=None, status=sys.stdout, warning=sys.stderr,
-                 freshenv=False, warningiserror=False, tags=None, verbosity=0):
+                 freshenv=False, warningiserror=False, tags=None, verbosity=0,
+                 parallel=0):
         self.verbosity = verbosity
         self.next_listener_id = 0
         self._extensions = {}
         self.outdir = outdir
         self.doctreedir = doctreedir
 
+        self.parallel = parallel
+
         if status is None:
             self._status = StringIO()
             self.quiet = True

File sphinx/cmdline.py

 -E            don't use a saved environment, always read all files
 -d <path>     path for the cached environment and doctree files
                 (default: outdir/.doctrees)
+-j <N>        build in parallel with N processes where possible
 
 Build configuration options
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
         nocolor()
 
     try:
-        opts, args = getopt.getopt(argv[1:], 'ab:t:d:c:CD:A:nNEqQWw:PThv',
+        opts, args = getopt.getopt(argv[1:], 'ab:t:d:c:CD:A:nNEqQWw:PThvj:',
                                    ['help', 'version'])
         allopts = set(opt[0] for opt in opts)
         if '-h' in allopts or '--help' in allopts:
     force_all = freshenv = warningiserror = use_pdb = False
     show_traceback = False
     verbosity = 0
+    parallel = 0
     status = sys.stdout
     warning = sys.stderr
     error = sys.stderr
         elif opt == '-v':
             verbosity += 1
             show_traceback = True
+        elif opt == '-j':
+            try:
+                parallel = int(val)
+            except ValueError:
+                print >>sys.stderr, ('Error: -j option argument must be an '
+                                     'integer.')
+                return 1
 
     if warning and warnfile:
         warnfp = open(warnfile, 'w')
     try:
         app = Sphinx(srcdir, confdir, outdir, doctreedir, buildername,
                      confoverrides, status, warning, freshenv,
-                     warningiserror, tags, verbosity)
+                     warningiserror, tags, verbosity, parallel)
         app.build(force_all, filenames)
         return app.statuscode
     except (Exception, KeyboardInterrupt), err: