Zachary Ware | a67b97f | 2014-04-29 09:45:33 -0500 | [diff] [blame] | 1 | @echo off |
Antoine Pitrou | 7f1e174 | 2011-02-25 14:19:48 +0000 | [diff] [blame] | 2 | setlocal |
| 3 | |
Zachary Ware | a67b97f | 2014-04-29 09:45:33 -0500 | [diff] [blame] | 4 | pushd %~dp0 |
| 5 | |
| 6 | set this=%~n0 |
| 7 | |
Zachary Ware | a37ff0f | 2014-04-18 15:10:40 -0500 | [diff] [blame] | 8 | if "%SPHINXBUILD%" EQU "" set SPHINXBUILD=sphinx-build |
| 9 | if "%PYTHON%" EQU "" set PYTHON=py |
Zachary Ware | a67b97f | 2014-04-29 09:45:33 -0500 | [diff] [blame] | 10 | |
| 11 | if DEFINED ProgramFiles(x86) set _PRGMFLS=%ProgramFiles(x86)% |
| 12 | if NOT DEFINED ProgramFiles(x86) set _PRGMFLS=%ProgramFiles% |
| 13 | if "%HTMLHELP%" EQU "" set HTMLHELP=%_PRGMFLS%\HTML Help Workshop\hhc.exe |
| 14 | |
Georg Brandl | 61bd1dc | 2014-09-30 22:56:38 +0200 | [diff] [blame] | 15 | if "%DISTVERSION%" EQU "" for /f "usebackq" %%v in (`%PYTHON% tools/patchlevel.py`) do set DISTVERSION=%%v |
Antoine Pitrou | 7f1e174 | 2011-02-25 14:19:48 +0000 | [diff] [blame] | 16 | |
Zachary Ware | a67b97f | 2014-04-29 09:45:33 -0500 | [diff] [blame] | 17 | if "%BUILDDIR%" EQU "" set BUILDDIR=build |
| 18 | |
| 19 | rem Targets that don't require sphinx-build |
Antoine Pitrou | 7f1e174 | 2011-02-25 14:19:48 +0000 | [diff] [blame] | 20 | if "%1" EQU "" goto help |
Zachary Ware | a67b97f | 2014-04-29 09:45:33 -0500 | [diff] [blame] | 21 | if "%1" EQU "help" goto help |
| 22 | if "%1" EQU "check" goto check |
| 23 | if "%1" EQU "serve" goto serve |
| 24 | if "%1" == "clean" ( |
| 25 | rmdir /q /s %BUILDDIR% |
| 26 | goto end |
| 27 | ) |
| 28 | |
| 29 | %SPHINXBUILD% 2> nul |
| 30 | if errorlevel 9009 ( |
| 31 | echo. |
| 32 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx |
| 33 | echo.installed, then set the SPHINXBUILD environment variable to point |
| 34 | echo.to the full path of the 'sphinx-build' executable. Alternatively you |
| 35 | echo.may add the Sphinx directory to PATH. |
| 36 | echo. |
| 37 | echo.If you don't have Sphinx installed, grab it from |
| 38 | echo.http://sphinx-doc.org/ |
| 39 | goto end |
| 40 | ) |
| 41 | |
| 42 | rem Targets that do require sphinx-build and have their own label |
| 43 | if "%1" EQU "htmlview" goto htmlview |
| 44 | |
| 45 | rem Everything else |
| 46 | goto build |
Antoine Pitrou | 7f1e174 | 2011-02-25 14:19:48 +0000 | [diff] [blame] | 47 | |
| 48 | :help |
Zachary Ware | a67b97f | 2014-04-29 09:45:33 -0500 | [diff] [blame] | 49 | echo.usage: %this% BUILDER [filename ...] |
Antoine Pitrou | 7f1e174 | 2011-02-25 14:19:48 +0000 | [diff] [blame] | 50 | echo. |
Zachary Ware | a67b97f | 2014-04-29 09:45:33 -0500 | [diff] [blame] | 51 | echo.Call %this% with the desired Sphinx builder as the first argument, e.g. |
| 52 | echo.``%this% html`` or ``%this% doctest``. Interesting targets that are |
| 53 | echo.always available include: |
Antoine Pitrou | 7f1e174 | 2011-02-25 14:19:48 +0000 | [diff] [blame] | 54 | echo. |
Zachary Ware | a67b97f | 2014-04-29 09:45:33 -0500 | [diff] [blame] | 55 | echo. Provided by Sphinx: |
| 56 | echo. html, htmlhelp, latex, text |
| 57 | echo. suspicious, linkcheck, changes, doctest |
| 58 | echo. Provided by this script: |
| 59 | echo. clean, check, serve, htmlview |
| 60 | echo. |
| 61 | echo.All arguments past the first one are passed through to sphinx-build as |
| 62 | echo.filenames to build or are ignored. See README.txt in this directory or |
| 63 | echo.the documentation for your version of Sphinx for more exhaustive lists |
| 64 | echo.of available targets and descriptions of each. |
| 65 | echo. |
| 66 | echo.This script assumes that the SPHINXBUILD environment variable contains |
| 67 | echo.a legitimate command for calling sphinx-build, or that sphinx-build is |
| 68 | echo.on your PATH if SPHINXBUILD is not set. Options for sphinx-build can |
| 69 | echo.be passed by setting the SPHINXOPTS environment variable. |
Antoine Pitrou | 7f1e174 | 2011-02-25 14:19:48 +0000 | [diff] [blame] | 70 | goto end |
| 71 | |
Antoine Pitrou | 7f1e174 | 2011-02-25 14:19:48 +0000 | [diff] [blame] | 72 | :build |
Zachary Ware | a67b97f | 2014-04-29 09:45:33 -0500 | [diff] [blame] | 73 | if NOT "%PAPER%" == "" ( |
| 74 | set SPHINXOPTS=-D latex_paper_size=%PAPER% %SPHINXOPTS% |
| 75 | ) |
| 76 | cmd /C %SPHINXBUILD% %SPHINXOPTS% -b%1 -dbuild\doctrees . %BUILDDIR%\%* |
| 77 | |
| 78 | if "%1" EQU "htmlhelp" ( |
Zachary Ware | 5989511 | 2014-06-10 12:07:45 -0500 | [diff] [blame] | 79 | if not exist "%HTMLHELP%" ( |
| 80 | echo. |
| 81 | echo.The HTML Help Workshop was not found. Set the HTMLHELP variable |
| 82 | echo.to the path to hhc.exe or download and install it from |
| 83 | echo.http://msdn.microsoft.com/en-us/library/ms669985 |
| 84 | rem Set errorlevel to 1 and exit |
| 85 | cmd /C exit /b 1 |
| 86 | goto end |
| 87 | ) |
Zachary Ware | a67b97f | 2014-04-29 09:45:33 -0500 | [diff] [blame] | 88 | cmd /C "%HTMLHELP%" build\htmlhelp\python%DISTVERSION:.=%.hhp |
| 89 | rem hhc.exe seems to always exit with code 1, reset to 0 for less than 2 |
| 90 | if not errorlevel 2 cmd /C exit /b 0 |
| 91 | ) |
| 92 | |
| 93 | echo. |
| 94 | if errorlevel 1 ( |
| 95 | echo.Build failed (exit code %ERRORLEVEL%^), check for error messages |
| 96 | echo.above. Any output will be found in %BUILDDIR%\%1 |
| 97 | ) else ( |
| 98 | echo.Build succeeded. All output should be in %BUILDDIR%\%1 |
| 99 | ) |
| 100 | goto end |
| 101 | |
| 102 | :htmlview |
| 103 | if NOT "%2" EQU "" ( |
| 104 | echo.Can't specify filenames to build with htmlview target, ignoring. |
| 105 | ) |
| 106 | cmd /C %this% html |
| 107 | |
| 108 | if EXIST %BUILDDIR%\html\index.html ( |
| 109 | echo.Opening %BUILDDIR%\html\index.html in the default web browser... |
| 110 | start %BUILDDIR%\html\index.html |
| 111 | ) |
| 112 | |
| 113 | goto end |
| 114 | |
| 115 | :check |
| 116 | cmd /C %PYTHON% tools\rstlint.py -i tools |
| 117 | goto end |
| 118 | |
| 119 | :serve |
| 120 | cmd /C %PYTHON% ..\Tools\scripts\serve.py %BUILDDIR%\html |
Antoine Pitrou | 7f1e174 | 2011-02-25 14:19:48 +0000 | [diff] [blame] | 121 | goto end |
| 122 | |
| 123 | :end |
Zachary Ware | a67b97f | 2014-04-29 09:45:33 -0500 | [diff] [blame] | 124 | popd |