Debian Codegraph @

cpython27/Doc/make.bat

raw
1 @echo off
2 setlocal
3
4 pushd %~dp0
5
6 set this=%~n0
7
8 call ..\PCbuild\find_python.bat %PYTHON%
9
10 if not defined PYTHON set PYTHON=py
11
12 if 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
22 if "%1" NEQ "htmlhelp" goto :skiphhcsearch
23 if exist "%HTMLHELP%" goto :skiphhcsearch
24
25 rem Search for HHC in likely places
26 set HTMLHELP=
27 where hhc /q && set HTMLHELP=hhc && goto :skiphhcsearch
28 where /R ..\externals hhc > "%TEMP%\hhc.loc" 2> nul && set /P HTMLHELP= < "%TEMP%\hhc.loc" & del "%TEMP%\hhc.loc"
29 if not exist "%HTMLHELP%" where /R "%ProgramFiles(x86)%" hhc > "%TEMP%\hhc.loc" 2> nul && set /P HTMLHELP= < "%TEMP%\hhc.loc" & del "%TEMP%\hhc.loc"
30 if not exist "%HTMLHELP%" where /R "%ProgramFiles%" hhc > "%TEMP%\hhc.loc" 2> nul && set /P HTMLHELP= < "%TEMP%\hhc.loc" & del "%TEMP%\hhc.loc"
31 if 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
40 if "%DISTVERSION%" EQU "" for /f "usebackq" %%v in (`%PYTHON% tools/extensions/patchlevel.py`) do set DISTVERSION=%%v
41
42 if "%BUILDDIR%" EQU "" set BUILDDIR=build
43
44 rem Targets that don't require sphinx-build
45 if "%1" EQU "" goto help
46 if "%1" EQU "help" goto help
47 if "%1" EQU "check" goto check
48 if "%1" EQU "serve" goto serve
49 if "%1" == "clean" (
50 rmdir /q /s "%BUILDDIR%"
51 goto end
52 )
53
54 %SPHINXBUILD% >nul 2> nul
55 if 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
68 rem Targets that do require sphinx-build and have their own label
69 if "%1" EQU "htmlview" goto htmlview
70
71 rem Everything else
72 goto build
73
74 :help
75 echo.usage: %this% BUILDER [filename ...]
76 echo.
77 echo.Call %this% with the desired Sphinx builder as the first argument, e.g.
78 echo.``%this% html`` or ``%this% doctest``. Interesting targets that are
79 echo.always available include:
80 echo.
81 echo. Provided by Sphinx:
82 echo. html, htmlhelp, latex, text
83 echo. suspicious, linkcheck, changes, doctest
84 echo. Provided by this script:
85 echo. clean, check, serve, htmlview
86 echo.
87 echo.All arguments past the first one are passed through to sphinx-build as
88 echo.filenames to build or are ignored. See README.txt in this directory or
89 echo.the documentation for your version of Sphinx for more exhaustive lists
90 echo.of available targets and descriptions of each.
91 echo.
92 echo.This script assumes that the SPHINXBUILD environment variable contains
93 echo.a legitimate command for calling sphinx-build, or that sphinx-build is
94 echo.on your PATH if SPHINXBUILD is not set. Options for sphinx-build can
95 echo.be passed by setting the SPHINXOPTS environment variable.
96 goto end
97
98 :build
99 if not exist "%BUILDDIR%" mkdir "%BUILDDIR%"
100 if NOT "%PAPER%" == "" (
101 set SPHINXOPTS=-D latex_elements.papersize=%PAPER% %SPHINXOPTS%
102 )
103 cmd /S /C "%SPHINXBUILD% %SPHINXOPTS% -b%1 -dbuild\doctrees . "%BUILDDIR%\%1" %2 %3 %4 %5 %6 %7 %8 %9"
104
105 if "%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
111 echo.
112 if 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 )
118 goto end
119
120 :htmlview
121 if NOT "%2" EQU "" (
122 echo.Can't specify filenames to build with htmlview target, ignoring.
123 )
124 cmd /C %this% html
125
126 if 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
131 goto end
132
133 :check
134 cmd /S /C "%PYTHON% tools\rstlint.py -i tools"
135 goto end
136
137 :serve
138 cmd /S /C "%PYTHON% ..\Tools\scripts\serve.py "%BUILDDIR%\html""
139 goto end
140
141 :end
142 popd