14c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware@echo off
24c9c848159b63fac440c29ffc2b437e055d355ccZachary Waresetlocal
34c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware
44c9c848159b63fac440c29ffc2b437e055d355ccZachary Warepushd %~dp0
54c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware
64c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareset this=%~n0
74c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware
84c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareif "%SPHINXBUILD%" EQU "" set SPHINXBUILD=sphinx-build
94c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareif "%PYTHON%" EQU "" set PYTHON=py
104c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware
11774ac377daf0da8eaddc578d883cd2002cb7a6a4Zachary Wareif "%1" NEQ "htmlhelp" goto :skiphhcsearch
12774ac377daf0da8eaddc578d883cd2002cb7a6a4Zachary Wareif exist "%HTMLHELP%" goto :skiphhcsearch
13774ac377daf0da8eaddc578d883cd2002cb7a6a4Zachary Ware
14774ac377daf0da8eaddc578d883cd2002cb7a6a4Zachary Warerem Search for HHC in likely places
15774ac377daf0da8eaddc578d883cd2002cb7a6a4Zachary Wareset HTMLHELP=
16774ac377daf0da8eaddc578d883cd2002cb7a6a4Zachary Warewhere hhc /q && set HTMLHELP=hhc && goto :skiphhcsearch
17774ac377daf0da8eaddc578d883cd2002cb7a6a4Zachary Warewhere /R ..\externals hhc > "%TEMP%\hhc.loc" 2> nul && set /P HTMLHELP= < "%TEMP%\hhc.loc" & del "%TEMP%\hhc.loc"
18774ac377daf0da8eaddc578d883cd2002cb7a6a4Zachary Wareif not exist "%HTMLHELP%" where /R "%ProgramFiles(x86)%" hhc > "%TEMP%\hhc.loc" 2> nul && set /P HTMLHELP= < "%TEMP%\hhc.loc" & del "%TEMP%\hhc.loc"
19774ac377daf0da8eaddc578d883cd2002cb7a6a4Zachary Wareif not exist "%HTMLHELP%" where /R "%ProgramFiles%" hhc > "%TEMP%\hhc.loc" 2> nul && set /P HTMLHELP= < "%TEMP%\hhc.loc" & del "%TEMP%\hhc.loc"
20e1f6805776b9b85791f9b3ae2cf998b7fed4a5bfSteve Dowerif not exist "%HTMLHELP%" (
21e1f6805776b9b85791f9b3ae2cf998b7fed4a5bfSteve Dower    echo.
22e1f6805776b9b85791f9b3ae2cf998b7fed4a5bfSteve Dower    echo.The HTML Help Workshop was not found.  Set the HTMLHELP variable
23e1f6805776b9b85791f9b3ae2cf998b7fed4a5bfSteve Dower    echo.to the path to hhc.exe or download and install it from
24e1f6805776b9b85791f9b3ae2cf998b7fed4a5bfSteve Dower    echo.http://msdn.microsoft.com/en-us/library/ms669985
25e1f6805776b9b85791f9b3ae2cf998b7fed4a5bfSteve Dower    exit /B 1
26e1f6805776b9b85791f9b3ae2cf998b7fed4a5bfSteve Dower)
27774ac377daf0da8eaddc578d883cd2002cb7a6a4Zachary Ware:skiphhcsearch
284c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware
294c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareif "%DISTVERSION%" EQU "" for /f "usebackq" %%v in (`%PYTHON% tools/extensions/patchlevel.py`) do set DISTVERSION=%%v
304c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware
314c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareif "%BUILDDIR%" EQU "" set BUILDDIR=build
324c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware
334c9c848159b63fac440c29ffc2b437e055d355ccZachary Warerem Targets that don't require sphinx-build
344c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareif "%1" EQU "" goto help
354c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareif "%1" EQU "help" goto help
364c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareif "%1" EQU "check" goto check
374c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareif "%1" EQU "serve" goto serve
384c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareif "%1" == "clean" (
394c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware    rmdir /q /s %BUILDDIR%
404c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware    goto end
414c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware)
424c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware
43003e929cdbff032143e58a4f41e7fc4e18e9b73bSteve Dower%SPHINXBUILD% >nul 2> nul
444c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareif errorlevel 9009 (
454c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware    echo.
464c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware    echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
474c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware    echo.installed, then set the SPHINXBUILD environment variable to point
484c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware    echo.to the full path of the 'sphinx-build' executable. Alternatively you
494c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware    echo.may add the Sphinx directory to PATH.
504c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware    echo.
514c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware    echo.If you don't have Sphinx installed, grab it from
524c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware    echo.http://sphinx-doc.org/
53774ac377daf0da8eaddc578d883cd2002cb7a6a4Zachary Ware    popd
54774ac377daf0da8eaddc578d883cd2002cb7a6a4Zachary Ware    exit /B 1
554c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware)
564c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware
574c9c848159b63fac440c29ffc2b437e055d355ccZachary Warerem Targets that do require sphinx-build and have their own label
584c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareif "%1" EQU "htmlview" goto htmlview
594c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware
604c9c848159b63fac440c29ffc2b437e055d355ccZachary Warerem Everything else
614c9c848159b63fac440c29ffc2b437e055d355ccZachary Waregoto build
624c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware
634c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware:help
644c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareecho.usage: %this% BUILDER [filename ...]
654c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareecho.
664c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareecho.Call %this% with the desired Sphinx builder as the first argument, e.g.
674c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareecho.``%this% html`` or ``%this% doctest``.  Interesting targets that are
684c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareecho.always available include:
694c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareecho.
704c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareecho.   Provided by Sphinx:
714c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareecho.      html, htmlhelp, latex, text
724c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareecho.      suspicious, linkcheck, changes, doctest
734c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareecho.   Provided by this script:
744c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareecho.      clean, check, serve, htmlview
754c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareecho.
764c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareecho.All arguments past the first one are passed through to sphinx-build as
77814213bdf1b95a5d863311b61c671010291f1197Mariattaecho.filenames to build or are ignored.  See README.rst in this directory or
784c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareecho.the documentation for your version of Sphinx for more exhaustive lists
794c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareecho.of available targets and descriptions of each.
804c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareecho.
814c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareecho.This script assumes that the SPHINXBUILD environment variable contains
824c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareecho.a legitimate command for calling sphinx-build, or that sphinx-build is
834c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareecho.on your PATH if SPHINXBUILD is not set.  Options for sphinx-build can
844c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareecho.be passed by setting the SPHINXOPTS environment variable.
854c9c848159b63fac440c29ffc2b437e055d355ccZachary Waregoto end
864c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware
874c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware:build
884c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareif NOT "%PAPER%" == "" (
89db3deb98e969d3f43b169cd320abd46b21a10c6dMariatta    set SPHINXOPTS=-D latex_elements.papersize=%PAPER% %SPHINXOPTS%
904c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware)
914c9c848159b63fac440c29ffc2b437e055d355ccZachary Warecmd /C %SPHINXBUILD% %SPHINXOPTS% -b%1 -dbuild\doctrees . %BUILDDIR%\%*
924c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware
934c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareif "%1" EQU "htmlhelp" (
944c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware    cmd /C "%HTMLHELP%" build\htmlhelp\python%DISTVERSION:.=%.hhp
954c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware    rem hhc.exe seems to always exit with code 1, reset to 0 for less than 2
964c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware    if not errorlevel 2 cmd /C exit /b 0
974c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware)
984c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware
994c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareecho.
1004c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareif errorlevel 1 (
1014c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware    echo.Build failed (exit code %ERRORLEVEL%^), check for error messages
1024c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware    echo.above.  Any output will be found in %BUILDDIR%\%1
1034c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware) else (
1044c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware    echo.Build succeeded. All output should be in %BUILDDIR%\%1
1054c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware)
1064c9c848159b63fac440c29ffc2b437e055d355ccZachary Waregoto end
1074c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware
1084c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware:htmlview
1094c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareif NOT "%2" EQU "" (
1104c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware    echo.Can't specify filenames to build with htmlview target, ignoring.
1114c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware)
1124c9c848159b63fac440c29ffc2b437e055d355ccZachary Warecmd /C %this% html
1134c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware
1144c9c848159b63fac440c29ffc2b437e055d355ccZachary Wareif EXIST %BUILDDIR%\html\index.html (
1154c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware    echo.Opening %BUILDDIR%\html\index.html in the default web browser...
1164c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware    start %BUILDDIR%\html\index.html
1174c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware)
1184c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware
1194c9c848159b63fac440c29ffc2b437e055d355ccZachary Waregoto end
1204c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware
1214c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware:check
1224c9c848159b63fac440c29ffc2b437e055d355ccZachary Warecmd /C %PYTHON% tools\rstlint.py -i tools
1234c9c848159b63fac440c29ffc2b437e055d355ccZachary Waregoto end
1244c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware
1254c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware:serve
1264c9c848159b63fac440c29ffc2b437e055d355ccZachary Warecmd /C %PYTHON% ..\Tools\scripts\serve.py %BUILDDIR%\html
1274c9c848159b63fac440c29ffc2b437e055d355ccZachary Waregoto end
1284c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware
1294c9c848159b63fac440c29ffc2b437e055d355ccZachary Ware:end
1304c9c848159b63fac440c29ffc2b437e055d355ccZachary Warepopd
131