diff options
author | Georg Brandl <georg@python.org> | 2014-01-11 19:36:05 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2014-01-11 19:36:05 +0100 |
commit | 91d92be8adae2e44e1e23e1c07b7088c35261abf (patch) | |
tree | 80127b8a18ea75e91efaeb5b547e6cd60aa5bb7e /sphinx/cmdline.py | |
parent | 1f83f01adfd3709dbce0059469b01d5078715a31 (diff) | |
download | sphinx-git-91d92be8adae2e44e1e23e1c07b7088c35261abf.tar.gz |
Add "make mode" to sphinx-build, invoked by the -M flag.
This is intended to do almost all of what the quickstart-generated Makefile
and make.bat did, but within Sphinx. The advantages are:
* no duplication between Unix and Windows files
* updates and fixes are propagated (the generated makefiles never update)
* more Python code, less shell code!
Diffstat (limited to 'sphinx/cmdline.py')
-rw-r--r-- | sphinx/cmdline.py | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/sphinx/cmdline.py b/sphinx/cmdline.py index e5ad3ab5b..f4a09e161 100644 --- a/sphinx/cmdline.py +++ b/sphinx/cmdline.py @@ -42,6 +42,7 @@ General options -d <path> path for the cached environment and doctree files (default: outdir/.doctrees) -j <N> build in parallel with N processes where possible +-M <builder> "make" mode -- used by Makefile, like "sphinx-build -M html" Build configuration options ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -82,19 +83,28 @@ def main(argv): # Windows' poor cmd box doesn't understand ANSI sequences nocolor() + # parse options try: 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: - usage(argv) - print >>sys.stderr - print >>sys.stderr, 'For more information, see '\ - '<http://sphinx-doc.org/>.' - return 0 - if '--version' in allopts: - print 'Sphinx (sphinx-build) %s' % __version__ - return 0 + except getopt.error, err: + usage(argv, 'Error: %s' % err) + return 1 + + # handle basic options + allopts = set(opt[0] for opt in opts) + # help and version options + if '-h' in allopts or '--help' in allopts: + usage(argv) + print >>sys.stderr + print >>sys.stderr, 'For more information, see <http://sphinx-doc.org/>.' + return 0 + if '--version' in allopts: + print 'Sphinx (sphinx-build) %s' % __version__ + return 0 + + # get paths (first and second positional argument) + try: srcdir = confdir = abspath(args[0]) if not path.isdir(srcdir): print >>sys.stderr, 'Error: Cannot find source directory `%s\'.' % ( @@ -103,12 +113,9 @@ def main(argv): if not path.isfile(path.join(srcdir, 'conf.py')) and \ '-c' not in allopts and '-C' not in allopts: print >>sys.stderr, ('Error: Source directory doesn\'t ' - 'contain conf.py file.') + 'contain a conf.py file.') return 1 outdir = abspath(args[1]) - except getopt.error, err: - usage(argv, 'Error: %s' % err) - return 1 except IndexError: usage(argv, 'Error: Insufficient arguments.') return 1 @@ -118,6 +125,7 @@ def main(argv): 'encoding (%r).' % fs_encoding) return 1 + # handle remaining filename arguments filenames = args[2:] err = 0 for filename in filenames: |