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