@@ -5,8 +5,11 @@ pushd %~dp0
5
5
6
6
set this = %~n0
7
7
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 (
10
13
%PYTHON% -c " import sphinx" > nul 2 > nul
11
14
if errorlevel 1 (
12
15
echo Installing sphinx with %PYTHON%
@@ -16,12 +19,23 @@ if not defined SPHINXBUILD if defined PYTHON (
16
19
set SPHINXBUILD = %PYTHON% -c " import sphinx, sys; sys.argv[0] = 'sphinx-build'; sys.exit(sphinx.main())"
17
20
)
18
21
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
21
24
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
25
39
26
40
if " %DISTVERSION% " EQU " " for /f " usebackq" %%v in (`%PYTHON% tools/extensions/patchlevel.py`) do set DISTVERSION = %%v
27
41
@@ -33,11 +47,11 @@ if "%1" EQU "help" goto help
33
47
if " %1 " EQU " check" goto check
34
48
if " %1 " EQU " serve" goto serve
35
49
if " %1 " == " clean" (
36
- rmdir /q /s %BUILDDIR%
50
+ rmdir /q /s " %BUILDDIR% "
37
51
goto end
38
52
)
39
53
40
- %SPHINXBUILD% 2 > nul
54
+ %SPHINXBUILD% > nul 2 > nul
41
55
if errorlevel 9009 (
42
56
echo .
43
57
echo .The 'sphinx-build' command was not found. Make sure you have Sphinx
@@ -47,7 +61,8 @@ if errorlevel 9009 (
47
61
echo .
48
62
echo .If you don't have Sphinx installed, grab it from
49
63
echo .http://sphinx-doc.org/
50
- goto end
64
+ popd
65
+ exit /B 1
51
66
)
52
67
53
68
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.
81
96
goto end
82
97
83
98
:build
99
+ if not exist " %BUILDDIR% " mkdir " %BUILDDIR% "
84
100
if NOT " %PAPER% " == " " (
85
101
set SPHINXOPTS = -D latex_elements.papersize=%PAPER% %SPHINXOPTS%
86
102
)
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 "
88
104
89
105
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"
100
107
rem hhc.exe seems to always exit with code 1, reset to 0 for less than 2
101
108
if not errorlevel 2 cmd /C exit /b 0
102
109
)
@@ -116,19 +123,19 @@ if NOT "%2" EQU "" (
116
123
)
117
124
cmd /C %this% html
118
125
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"
122
129
)
123
130
124
131
goto end
125
132
126
133
:check
127
- cmd /C %PYTHON% tools\rstlint.py -i tools
134
+ cmd /S /C " %PYTHON% tools\rstlint.py -i tools"
128
135
goto end
129
136
130
137
:serve
131
- cmd /C %PYTHON% ..\Tools\scripts\serve.py %BUILDDIR% \html
138
+ cmd /S /C " %PYTHON% ..\Tools\scripts\serve.py " %BUILDDIR% \html" "
132
139
goto end
133
140
134
141
:end
0 commit comments