mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Introduce a "-j" flag for parallel build.
This commit is contained in:
parent
b831acf617
commit
c88ba504f3
@ -61,7 +61,8 @@ class Sphinx(object):
|
|||||||
|
|
||||||
def __init__(self, srcdir, confdir, outdir, doctreedir, buildername,
|
def __init__(self, srcdir, confdir, outdir, doctreedir, buildername,
|
||||||
confoverrides=None, status=sys.stdout, warning=sys.stderr,
|
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.verbosity = verbosity
|
||||||
self.next_listener_id = 0
|
self.next_listener_id = 0
|
||||||
self._extensions = {}
|
self._extensions = {}
|
||||||
@ -76,6 +77,8 @@ class Sphinx(object):
|
|||||||
self.outdir = outdir
|
self.outdir = outdir
|
||||||
self.doctreedir = doctreedir
|
self.doctreedir = doctreedir
|
||||||
|
|
||||||
|
self.parallel = parallel
|
||||||
|
|
||||||
if status is None:
|
if status is None:
|
||||||
self._status = StringIO()
|
self._status = StringIO()
|
||||||
self.quiet = True
|
self.quiet = True
|
||||||
|
@ -48,6 +48,7 @@ General options
|
|||||||
-E don't use a saved environment, always read all files
|
-E don't use a saved environment, always read all files
|
||||||
-d <path> path for the cached environment and doctree files
|
-d <path> path for the cached environment and doctree files
|
||||||
(default: outdir/.doctrees)
|
(default: outdir/.doctrees)
|
||||||
|
-j <N> build in parallel with N processes where possible
|
||||||
|
|
||||||
Build configuration options
|
Build configuration options
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
@ -89,7 +90,7 @@ def main(argv):
|
|||||||
nocolor()
|
nocolor()
|
||||||
|
|
||||||
try:
|
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'])
|
['help', 'version'])
|
||||||
allopts = set(opt[0] for opt in opts)
|
allopts = set(opt[0] for opt in opts)
|
||||||
if '-h' in allopts or '--help' in allopts:
|
if '-h' in allopts or '--help' in allopts:
|
||||||
@ -139,6 +140,7 @@ def main(argv):
|
|||||||
force_all = freshenv = warningiserror = use_pdb = False
|
force_all = freshenv = warningiserror = use_pdb = False
|
||||||
show_traceback = False
|
show_traceback = False
|
||||||
verbosity = 0
|
verbosity = 0
|
||||||
|
parallel = 0
|
||||||
status = sys.stdout
|
status = sys.stdout
|
||||||
warning = sys.stderr
|
warning = sys.stderr
|
||||||
error = sys.stderr
|
error = sys.stderr
|
||||||
@ -220,6 +222,13 @@ def main(argv):
|
|||||||
elif opt == '-v':
|
elif opt == '-v':
|
||||||
verbosity += 1
|
verbosity += 1
|
||||||
show_traceback = True
|
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:
|
if warning and warnfile:
|
||||||
warnfp = open(warnfile, 'w')
|
warnfp = open(warnfile, 'w')
|
||||||
@ -234,7 +243,7 @@ def main(argv):
|
|||||||
try:
|
try:
|
||||||
app = Sphinx(srcdir, confdir, outdir, doctreedir, buildername,
|
app = Sphinx(srcdir, confdir, outdir, doctreedir, buildername,
|
||||||
confoverrides, status, warning, freshenv,
|
confoverrides, status, warning, freshenv,
|
||||||
warningiserror, tags, verbosity)
|
warningiserror, tags, verbosity, parallel)
|
||||||
app.build(force_all, filenames)
|
app.build(force_all, filenames)
|
||||||
return app.statuscode
|
return app.statuscode
|
||||||
except (Exception, KeyboardInterrupt), err:
|
except (Exception, KeyboardInterrupt), err:
|
||||||
|
Loading…
Reference in New Issue
Block a user