FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Issue #17386: Expand Doc/make.bat to be much more similar to Doc/Make… · python/cpython@a67b97f · GitHub

Repository navigation

Commit a67b97f

Browse files
committed
Issue #17386: Expand Doc/make.bat to be much more similar to Doc/Makefile
1 parent 1de519c commit a67b97f

2 files changed

Lines changed: 101 additions & 23 deletions

File tree

‎Doc/make.bat‎

Lines changed: 98 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,115 @@
1-
@@echo off
1+
@echo off
22
setlocal
33

4+
pushd %~dp0
5+
6+
set this=%~n0
7+
48
if "%SPHINXBUILD%" EQU "" set SPHINXBUILD=sphinx-build
59
if "%PYTHON%" EQU "" set PYTHON=py
6-
if "%HTMLHELP%" EQU "" set HTMLHELP=%ProgramFiles%\HTML Help Workshop\hhc.exe
10+
11+
if DEFINED ProgramFiles(x86) set _PRGMFLS=%ProgramFiles(x86)%
12+
if NOT DEFINED ProgramFiles(x86) set _PRGMFLS=%ProgramFiles%
13+
if "%HTMLHELP%" EQU "" set HTMLHELP=%_PRGMFLS%\HTML Help Workshop\hhc.exe
14+
715
if "%DISTVERSION%" EQU "" for /f "usebackq" %%v in (`%PYTHON% tools/sphinxext/patchlevel.py`) do set DISTVERSION=%%v
816

17+
if "%BUILDDIR%" EQU "" set BUILDDIR=build
18+
19+
rem Targets that don't require sphinx-build
920
if "%1" EQU "" goto help
10-
if "%1" EQU "html" goto build
11-
if "%1" EQU "htmlhelp" goto build
12-
if "%1" EQU "latex" goto build
13-
if "%1" EQU "text" goto build
14-
if "%1" EQU "suspicious" goto build
15-
if "%1" EQU "linkcheck" goto build
16-
if "%1" EQU "changes" goto build
21+
if "%1" EQU "help" goto help
22+
if "%1" EQU "check" goto check
23+
if "%1" EQU "serve" goto serve
24+
if "%1" == "clean" (
25+
rmdir /q /s %BUILDDIR%
26+
goto end
27+
)
28+
29+
%SPHINXBUILD% 2> nul
30+
if errorlevel 9009 (
31+
echo.
32+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
33+
echo.installed, then set the SPHINXBUILD environment variable to point
34+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
35+
echo.may add the Sphinx directory to PATH.
36+
echo.
37+
echo.If you don't have Sphinx installed, grab it from
38+
echo.http://sphinx-doc.org/
39+
goto end
40+
)
41+
42+
rem Targets that do require sphinx-build and have their own label
43+
if "%1" EQU "htmlview" goto htmlview
44+
45+
rem Everything else
46+
goto build
1747

1848
:help
19-
set this=%~n0
20-
echo HELP
49+
echo.usage: %this% BUILDER [filename ...]
50+
echo.
51+
echo.Call %this% with the desired Sphinx builder as the first argument, e.g.
52+
echo.``%this% html`` or ``%this% doctest``. Interesting targets that are
53+
echo.always available include:
54+
echo.
55+
echo. Provided by Sphinx:
56+
echo. html, htmlhelp, latex, text
57+
echo. suspicious, linkcheck, changes, doctest
58+
echo. Provided by this script:
59+
echo. clean, check, serve, htmlview
2160
echo.
22-
echo %this% html
23-
echo %this% htmlhelp
24-
echo %this% latex
25-
echo %this% text
26-
echo %this% suspicious
27-
echo %this% linkcheck
28-
echo %this% changes
61+
echo.All arguments past the first one are passed through to sphinx-build as
62+
echo.filenames to build or are ignored. See README.txt in this directory or
63+
echo.the documentation for your version of Sphinx for more exhaustive lists
64+
echo.of available targets and descriptions of each.
2965
echo.
66+
echo.This script assumes that the SPHINXBUILD environment variable contains
67+
echo.a legitimate command for calling sphinx-build, or that sphinx-build is
68+
echo.on your PATH if SPHINXBUILD is not set. Options for sphinx-build can
69+
echo.be passed by setting the SPHINXOPTS environment variable.
3070
goto end
3171

3272
:build
33-
if not exist build mkdir build
34-
if not exist build\%1 mkdir build\%1
35-
if not exist build\doctrees mkdir build\doctrees
36-
cmd /C %SPHINXBUILD% -b%1 -dbuild\doctrees . build\%*
37-
if "%1" EQU "htmlhelp" "%HTMLHELP%" build\htmlhelp\python%DISTVERSION:.=%.hhp
73+
if NOT "%PAPER%" == "" (
74+
set SPHINXOPTS=-D latex_paper_size=%PAPER% %SPHINXOPTS%
75+
)
76+
cmd /C %SPHINXBUILD% %SPHINXOPTS% -b%1 -dbuild\doctrees . %BUILDDIR%\%*
77+
78+
if "%1" EQU "htmlhelp" (
79+
cmd /C "%HTMLHELP%" build\htmlhelp\python%DISTVERSION:.=%.hhp
80+
rem hhc.exe seems to always exit with code 1, reset to 0 for less than 2
81+
if not errorlevel 2 cmd /C exit /b 0
82+
)
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+
93+
:htmlview
94+
if NOT "%2" EQU "" (
95+
echo.Can't specify filenames to build with htmlview target, ignoring.
96+
)
97+
cmd /C %this% html
98+
99+
if EXIST %BUILDDIR%\html\index.html (
100+
echo.Opening %BUILDDIR%\html\index.html in the default web browser...
101+
start %BUILDDIR%\html\index.html
102+
)
103+
104+
goto end
105+
106+
:check
107+
cmd /C %PYTHON% tools\rstlint.py -i tools
108+
goto end
109+
110+
:serve
111+
cmd /C %PYTHON% ..\Tools\scripts\serve.py %BUILDDIR%\html
38112
goto end
39113

40114
:end
115+
popd

‎Misc/NEWS‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,9 @@ C API
237237
Documentation
238238
-------------
239239

240+
- Issue #17386: Expanded functionality of the ``Doc/make.bat`` script to make
241+
it much more comparable to ``Doc/Makefile``.
242+
240243
- Issue #21043: Remove the recommendation for specific CA organizations and to
241244
mention the ability to load the OS certificates.
242245

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL