|
1 | | -@@echo off |
| 1 | +@echo off |
2 | 2 | setlocal |
3 | 3 |
|
| 4 | +pushd %~dp0 |
| 5 | + |
| 6 | +set this=%~n0 |
| 7 | + |
4 | 8 | if "%SPHINXBUILD%" EQU "" set SPHINXBUILD=sphinx-build |
5 | 9 | if "%PYTHON%" EQU "" set PYTHON=py |
6 | | -if "%HTMLHELP%" EQU "" set HTMLHELP=%ProgramFiles%\HTML Help Workshop\hhc.exe |
| 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 | + |
7 | 15 | if "%DISTVERSION%" EQU "" for /f "usebackq" %%v in (`%PYTHON% tools/sphinxext/patchlevel.py`) do set DISTVERSION=%%v |
8 | 16 |
|
| 17 | +if "%BUILDDIR%" EQU "" set BUILDDIR=build |
| 18 | + |
| 19 | +rem Targets that don't require sphinx-build |
9 | 20 | if "%1" EQU "" goto help |
10 | | -if "%1" EQU "html" goto build |
11 | | -if "%1" EQU "htmlhelp" goto build |
12 | | -if "%1" EQU "latex" goto build |
13 | | -if "%1" EQU "text" goto build |
14 | | -if "%1" EQU "suspicious" goto build |
15 | | -if "%1" EQU "linkcheck" goto build |
16 | | -if "%1" EQU "changes" goto build |
| 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 |
17 | 47 |
|
18 | 48 | :help |
19 | | -set this=%~n0 |
20 | | -echo HELP |
| 49 | +echo.usage: %this% BUILDER [filename ...] |
| 50 | +echo. |
| 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: |
| 54 | +echo. |
| 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 |
21 | 60 | echo. |
22 | | -echo %this% html |
23 | | -echo %this% htmlhelp |
24 | | -echo %this% latex |
25 | | -echo %this% text |
26 | | -echo %this% suspicious |
27 | | -echo %this% linkcheck |
28 | | -echo %this% changes |
| 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. |
29 | 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. |
30 | 70 | goto end |
31 | 71 |
|
32 | 72 | :build |
33 | | -if not exist build mkdir build |
34 | | -if not exist build\%1 mkdir build\%1 |
35 | | -if not exist build\doctrees mkdir build\doctrees |
36 | | -cmd /C %SPHINXBUILD% -b%1 -dbuild\doctrees . build\%* |
37 | | -if "%1" EQU "htmlhelp" "%HTMLHELP%" build\htmlhelp\python%DISTVERSION:.=%.hhp |
| 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" ( |
| 79 | + cmd /C "%HTMLHELP%" build\htmlhelp\python%DISTVERSION:.=%.hhp |
| 80 | + rem hhc.exe seems to always exit with code 1, reset to 0 for less than 2 |
| 81 | + if not errorlevel 2 cmd /C exit /b 0 |
| 82 | +) |
| 83 | + |
| 84 | +echo. |
| 85 | +if errorlevel 1 ( |
| 86 | + echo.Build failed (exit code %ERRORLEVEL%^), check for error messages |
| 87 | + echo.above. Any output will be found in %BUILDDIR%\%1 |
| 88 | +) else ( |
| 89 | + echo.Build succeeded. All output should be in %BUILDDIR%\%1 |
| 90 | +) |
| 91 | +goto end |
| 92 | + |
| 93 | +:htmlview |
| 94 | +if NOT "%2" EQU "" ( |
| 95 | + echo.Can't specify filenames to build with htmlview target, ignoring. |
| 96 | +) |
| 97 | +cmd /C %this% html |
| 98 | + |
| 99 | +if EXIST %BUILDDIR%\html\index.html ( |
| 100 | + echo.Opening %BUILDDIR%\html\index.html in the default web browser... |
| 101 | + start %BUILDDIR%\html\index.html |
| 102 | +) |
| 103 | + |
| 104 | +goto end |
| 105 | + |
| 106 | +:check |
| 107 | +cmd /C %PYTHON% tools\rstlint.py -i tools |
| 108 | +goto end |
| 109 | + |
| 110 | +:serve |
| 111 | +cmd /C %PYTHON% ..\Tools\scripts\serve.py %BUILDDIR%\html |
38 | 112 | goto end |
39 | 113 |
|
40 | 114 | :end |
| 115 | +popd |
0 commit comments