Skip to content

Commit 42ca836

Browse files
andresdelfinozooba
authored andcommitted
bpo-33845: Update Doc\make.bat on 2.7 to bring it on par to master version (GH-7667)
1 parent 4fde701 commit 42ca836

File tree

1 file changed

+33
-26
lines changed

1 file changed

+33
-26
lines changed

Doc/make.bat

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ pushd %~dp0
55

66
set this=%~n0
77

8-
call ..\PCBuild\find_python.bat %PYTHON%
9-
if not defined SPHINXBUILD if defined PYTHON (
8+
call ..\PCbuild\find_python.bat %PYTHON%
9+
10+
if not defined PYTHON set PYTHON=py
11+
12+
if not defined SPHINXBUILD (
1013
%PYTHON% -c "import sphinx" > nul 2> nul
1114
if errorlevel 1 (
1215
echo Installing sphinx with %PYTHON%
@@ -16,12 +19,23 @@ if not defined SPHINXBUILD if defined PYTHON (
1619
set SPHINXBUILD=%PYTHON% -c "import sphinx, sys; sys.argv[0] = 'sphinx-build'; sys.exit(sphinx.main())"
1720
)
1821

19-
if not defined PYTHON set PYTHON=py
20-
if not defined SPHINXBUILD set SPHINXBUILD=sphinx-build
22+
if "%1" NEQ "htmlhelp" goto :skiphhcsearch
23+
if exist "%HTMLHELP%" goto :skiphhcsearch
2124

22-
if DEFINED ProgramFiles(x86) set _PRGMFLS=%ProgramFiles(x86)%
23-
if NOT DEFINED ProgramFiles(x86) set _PRGMFLS=%ProgramFiles%
24-
if "%HTMLHELP%" EQU "" set HTMLHELP=%_PRGMFLS%\HTML Help Workshop\hhc.exe
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
2539

2640
if "%DISTVERSION%" EQU "" for /f "usebackq" %%v in (`%PYTHON% tools/extensions/patchlevel.py`) do set DISTVERSION=%%v
2741

@@ -33,11 +47,11 @@ if "%1" EQU "help" goto help
3347
if "%1" EQU "check" goto check
3448
if "%1" EQU "serve" goto serve
3549
if "%1" == "clean" (
36-
rmdir /q /s %BUILDDIR%
50+
rmdir /q /s "%BUILDDIR%"
3751
goto end
3852
)
3953

40-
%SPHINXBUILD% 2> nul
54+
%SPHINXBUILD% >nul 2> nul
4155
if errorlevel 9009 (
4256
echo.
4357
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
@@ -47,7 +61,8 @@ if errorlevel 9009 (
4761
echo.
4862
echo.If you don't have Sphinx installed, grab it from
4963
echo.http://sphinx-doc.org/
50-
goto end
64+
popd
65+
exit /B 1
5166
)
5267

5368
rem Targets that do require sphinx-build and have their own label
@@ -81,22 +96,14 @@ echo.be passed by setting the SPHINXOPTS environment variable.
8196
goto end
8297

8398
:build
99+
if not exist "%BUILDDIR%" mkdir "%BUILDDIR%"
84100
if NOT "%PAPER%" == "" (
85101
set SPHINXOPTS=-D latex_elements.papersize=%PAPER% %SPHINXOPTS%
86102
)
87-
cmd /C "%SPHINXBUILD% %SPHINXOPTS% -b%1 -dbuild\doctrees . %BUILDDIR%\%*"
103+
cmd /S /C "%SPHINXBUILD% %SPHINXOPTS% -b%1 -dbuild\doctrees . "%BUILDDIR%\%1" %2 %3 %4 %5 %6 %7 %8 %9"
88104

89105
if "%1" EQU "htmlhelp" (
90-
if not exist "%HTMLHELP%" (
91-
echo.
92-
echo.The HTML Help Workshop was not found. Set the HTMLHELP variable
93-
echo.to the path to hhc.exe or download and install it from
94-
echo.http://msdn.microsoft.com/en-us/library/ms669985
95-
rem Set errorlevel to 1 and exit
96-
cmd /C exit /b 1
97-
goto end
98-
)
99-
cmd /C "%HTMLHELP%" build\htmlhelp\python%DISTVERSION:.=%.hhp
106+
"%HTMLHELP%" "%BUILDDIR%\htmlhelp\python%DISTVERSION:.=%.hhp"
100107
rem hhc.exe seems to always exit with code 1, reset to 0 for less than 2
101108
if not errorlevel 2 cmd /C exit /b 0
102109
)
@@ -116,19 +123,19 @@ if NOT "%2" EQU "" (
116123
)
117124
cmd /C %this% html
118125

119-
if EXIST %BUILDDIR%\html\index.html (
120-
echo.Opening %BUILDDIR%\html\index.html in the default web browser...
121-
start %BUILDDIR%\html\index.html
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"
122129
)
123130

124131
goto end
125132

126133
:check
127-
cmd /C %PYTHON% tools\rstlint.py -i tools
134+
cmd /S /C "%PYTHON% tools\rstlint.py -i tools"
128135
goto end
129136

130137
:serve
131-
cmd /C %PYTHON% ..\Tools\scripts\serve.py %BUILDDIR%\html
138+
cmd /S /C "%PYTHON% ..\Tools\scripts\serve.py "%BUILDDIR%\html""
132139
goto end
133140

134141
:end

0 commit comments

Comments
 (0)