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/quickstart.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/quickstart.py')
-rw-r--r-- | sphinx/quickstart.py | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py index f77e2f22b..7ce3ad848 100644 --- a/sphinx/quickstart.py +++ b/sphinx/quickstart.py @@ -837,6 +837,72 @@ if "%%1" == "pseudoxml" ( :end ''' +# This will become the Makefile template for Sphinx 1.5. +MAKEFILE_NEW = u'''\ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +SPHINXPROJ = %(project_fn)s +BUILDDIR = %(rbuilddir)s + +# User-friendly check for sphinx-build +ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) +$(error \ +The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx \ +installed, then set the SPHINXBUILD environment variable to point \ +to the full path of the '$(SPHINXBUILD)' executable. Alternatively you \ +can add the directory with the executable to your PATH. \ +If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) +endif + +# Has to be explicit, otherwise we don't get "make" without targets right. +help: +\t@$(SPHINXBUILD) -M help "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +# Catch-all target using the new "make mode" option. +%: +\t@$(SPHINXBUILD) -M $@ "$(BUILDDIR)" $(SPHINXOPTS) $(O) +''' + +# This will become the make.bat template for Sphinx 1.5. +BATCHFILE_NEW = u'''\ +@ECHO OFF + +REM Command file for Sphinx documentation + +if "%%SPHINXBUILD%%" == "" ( +\tset SPHINXBUILD=sphinx-build +) +set BUILDDIR=%(rbuilddir)s +set SPHINXPROJ=%(project_fn)s + +if "%%1" == "" goto help + +%%SPHINXBUILD%% 2> nul +if errorlevel 9009 ( +\techo. +\techo.The 'sphinx-build' command was not found. Make sure you have Sphinx +\techo.installed, then set the SPHINXBUILD environment variable to point +\techo.to the full path of the 'sphinx-build' executable. Alternatively you +\techo.may add the Sphinx directory to PATH. +\techo. +\techo.If you don't have Sphinx installed, grab it from +\techo.http://sphinx-doc.org/ +\texit /b 1 +) + +%%SPHINXBUILD%% -M %%1 %%BUILDDIR%% %%SPHINXOPTS%% +goto end + +:help +%%SPHINXBUILD%% -M help %%BUILDDIR%% %%SPHINXOPTS%% + +:end +''' + def mkdir_p(dir): if path.isdir(dir): |