python-guide
253 строки · 6.5 Кб
1@ECHO OFF
2
3REM Command file for Sphinx documentation
4
5if "%SPHINXBUILD%" == "" (
6set SPHINXBUILD=sphinx-build
7)
8set BUILDDIR=_build
9set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
10set I18NSPHINXOPTS=%SPHINXOPTS% .
11if NOT "%PAPER%" == "" (
12set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
13set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
14)
15
16if "%1" == "" goto help
17
18if "%1" == "help" (
19:help
20echo.Please use `make ^<target^>` where ^<target^> is one of
21echo. html to make standalone HTML files
22echo. dirhtml to make HTML files named index.html in directories
23echo. singlehtml to make a single large HTML file
24echo. pickle to make pickle files
25echo. json to make JSON files
26echo. htmlhelp to make HTML files and a HTML help project
27echo. qthelp to make HTML files and a qthelp project
28echo. devhelp to make HTML files and a Devhelp project
29echo. epub to make an epub
30echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
31echo. text to make text files
32echo. man to make manual pages
33echo. texinfo to make Texinfo files
34echo. gettext to make PO message catalogs
35echo. changes to make an overview over all changed/added/deprecated items
36echo. xml to make Docutils-native XML files
37echo. pseudoxml to make pseudoxml-XML files for display purposes
38echo. linkcheck to check all external links for integrity
39echo. doctest to run all doctests embedded in the documentation if enabled
40goto end
41)
42
43if "%1" == "clean" (
44for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
45del /q /s %BUILDDIR%\*
46goto end
47)
48
49
50REM Check if sphinx-build is available and fallback to Python version if any
51%SPHINXBUILD% 2> nul
52if errorlevel 9009 goto sphinx_python
53goto sphinx_ok
54
55:sphinx_python
56
57set SPHINXBUILD=python -m sphinx.__init__
58%SPHINXBUILD% 2> nul
59if errorlevel 9009 (
60echo.
61echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
62echo.installed, then set the SPHINXBUILD environment variable to point
63echo.to the full path of the 'sphinx-build' executable. Alternatively you
64echo.may add the Sphinx directory to PATH.
65echo.
66echo.If you don't have Sphinx installed, grab it from
67echo.http://sphinx-doc.org/
68exit /b 1
69)
70
71:sphinx_ok
72
73
74if "%1" == "html" (
75%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
76if errorlevel 1 exit /b 1
77echo.
78echo.Build finished. The HTML pages are in %BUILDDIR%/html.
79goto end
80)
81
82if "%1" == "dirhtml" (
83%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
84if errorlevel 1 exit /b 1
85echo.
86echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
87goto end
88)
89
90if "%1" == "singlehtml" (
91%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
92if errorlevel 1 exit /b 1
93echo.
94echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
95goto end
96)
97
98if "%1" == "pickle" (
99%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
100if errorlevel 1 exit /b 1
101echo.
102echo.Build finished; now you can process the pickle files.
103goto end
104)
105
106if "%1" == "json" (
107%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
108if errorlevel 1 exit /b 1
109echo.
110echo.Build finished; now you can process the JSON files.
111goto end
112)
113
114if "%1" == "htmlhelp" (
115%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
116if errorlevel 1 exit /b 1
117echo.
118echo.Build finished; now you can run HTML Help Workshop with the ^
119.hhp project file in %BUILDDIR%/htmlhelp.
120goto end
121)
122
123if "%1" == "qthelp" (
124%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
125if errorlevel 1 exit /b 1
126echo.
127echo.Build finished; now you can run "qcollectiongenerator" with the ^
128.qhcp project file in %BUILDDIR%/qthelp, like this:
129echo.^> qcollectiongenerator %BUILDDIR%\qthelp\pythonguide.qhcp
130echo.To view the help file:
131echo.^> assistant -collectionFile %BUILDDIR%\qthelp\pythonguide.ghc
132goto end
133)
134
135if "%1" == "devhelp" (
136%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
137if errorlevel 1 exit /b 1
138echo.
139echo.Build finished.
140goto end
141)
142
143if "%1" == "epub" (
144%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
145if errorlevel 1 exit /b 1
146echo.
147echo.Build finished. The epub file is in %BUILDDIR%/epub.
148goto end
149)
150
151if "%1" == "latex" (
152%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
153if errorlevel 1 exit /b 1
154echo.
155echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
156goto end
157)
158
159if "%1" == "latexpdf" (
160%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
161cd %BUILDDIR%/latex
162make all-pdf
163cd %BUILDDIR%/..
164echo.
165echo.Build finished; the PDF files are in %BUILDDIR%/latex.
166goto end
167)
168
169if "%1" == "latexpdfja" (
170%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
171cd %BUILDDIR%/latex
172make all-pdf-ja
173cd %BUILDDIR%/..
174echo.
175echo.Build finished; the PDF files are in %BUILDDIR%/latex.
176goto end
177)
178
179if "%1" == "text" (
180%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
181if errorlevel 1 exit /b 1
182echo.
183echo.Build finished. The text files are in %BUILDDIR%/text.
184goto end
185)
186
187if "%1" == "man" (
188%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
189if errorlevel 1 exit /b 1
190echo.
191echo.Build finished. The manual pages are in %BUILDDIR%/man.
192goto end
193)
194
195if "%1" == "texinfo" (
196%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
197if errorlevel 1 exit /b 1
198echo.
199echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
200goto end
201)
202
203if "%1" == "gettext" (
204%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
205if errorlevel 1 exit /b 1
206echo.
207echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
208goto end
209)
210
211if "%1" == "changes" (
212%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
213if errorlevel 1 exit /b 1
214echo.
215echo.The overview file is in %BUILDDIR%/changes.
216goto end
217)
218
219if "%1" == "linkcheck" (
220%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
221if errorlevel 1 exit /b 1
222echo.
223echo.Link check complete; look for any errors in the above output ^
224or in %BUILDDIR%/linkcheck/output.txt.
225goto end
226)
227
228if "%1" == "doctest" (
229%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
230if errorlevel 1 exit /b 1
231echo.
232echo.Testing of doctests in the sources finished, look at the ^
233results in %BUILDDIR%/doctest/output.txt.
234goto end
235)
236
237if "%1" == "xml" (
238%SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml
239if errorlevel 1 exit /b 1
240echo.
241echo.Build finished. The XML files are in %BUILDDIR%/xml.
242goto end
243)
244
245if "%1" == "pseudoxml" (
246%SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml
247if errorlevel 1 exit /b 1
248echo.
249echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml.
250goto end
251)
252
253:end
254