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