You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
4.1 KiB

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