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