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.

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