Skip to content

Commit 1753f45

Browse files
committed
Merge pull request realpython#368 from techtonik/sphinx-works
Bring generated makefiles up to date with Sphinx 1.2
2 parents 9165aef + f9dc281 commit 1753f45

File tree

3 files changed

+155
-10
lines changed

3 files changed

+155
-10
lines changed

docs/Makefile

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,19 @@ SPHINXBUILD = sphinx-build
77
PAPER =
88
BUILDDIR = _build
99

10+
# User-friendly check for sphinx-build
11+
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
12+
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
13+
endif
14+
1015
# Internal variables.
1116
PAPEROPT_a4 = -D latex_paper_size=a4
1217
PAPEROPT_letter = -D latex_paper_size=letter
1318
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
19+
# the i18n builder cannot share the environment and doctrees with the others
20+
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
1421

15-
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest
22+
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
1623

1724
help:
1825
@echo "Please use \`make <target>' where <target> is one of"
@@ -27,14 +34,20 @@ help:
2734
@echo " epub to make an epub"
2835
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
2936
@echo " latexpdf to make LaTeX files and run them through pdflatex"
37+
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
3038
@echo " text to make text files"
3139
@echo " man to make manual pages"
40+
@echo " texinfo to make Texinfo files"
41+
@echo " info to make Texinfo files and run them through makeinfo"
42+
@echo " gettext to make PO message catalogs"
3243
@echo " changes to make an overview of all changed/added/deprecated items"
44+
@echo " xml to make Docutils-native XML files"
45+
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
3346
@echo " linkcheck to check all external links for integrity"
3447
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
3548

3649
clean:
37-
-rm -rf $(BUILDDIR)/*
50+
rm -rf $(BUILDDIR)/*
3851

3952
html:
4053
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@@ -72,17 +85,17 @@ qthelp:
7285
@echo
7386
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
7487
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
75-
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/osxpython.qhcp"
88+
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/pythonguide.qhcp"
7689
@echo "To view the help file:"
77-
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/osxpython.qhc"
90+
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/pythonguide.qhc"
7891

7992
devhelp:
8093
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
8194
@echo
8295
@echo "Build finished."
8396
@echo "To view the help file:"
84-
@echo "# mkdir -p $$HOME/.local/share/devhelp/osxpython"
85-
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/osxpython"
97+
@echo "# mkdir -p $$HOME/.local/share/devhelp/pythonguide"
98+
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/pythonguide"
8699
@echo "# devhelp"
87100

88101
epub:
@@ -100,7 +113,13 @@ latex:
100113
latexpdf:
101114
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
102115
@echo "Running LaTeX files through pdflatex..."
103-
make -C $(BUILDDIR)/latex all-pdf
116+
$(MAKE) -C $(BUILDDIR)/latex all-pdf
117+
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
118+
119+
latexpdfja:
120+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
121+
@echo "Running LaTeX files through platex and dvipdfmx..."
122+
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
104123
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
105124

106125
text:
@@ -113,6 +132,24 @@ man:
113132
@echo
114133
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
115134

135+
texinfo:
136+
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
137+
@echo
138+
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
139+
@echo "Run \`make' in that directory to run these through makeinfo" \
140+
"(use \`make info' here to do that automatically)."
141+
142+
info:
143+
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
144+
@echo "Running Texinfo files through makeinfo..."
145+
make -C $(BUILDDIR)/texinfo info
146+
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
147+
148+
gettext:
149+
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
150+
@echo
151+
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
152+
116153
changes:
117154
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
118155
@echo
@@ -128,3 +165,13 @@ doctest:
128165
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
129166
@echo "Testing of doctests in the sources finished, look at the " \
130167
"results in $(BUILDDIR)/doctest/output.txt."
168+
169+
xml:
170+
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
171+
@echo
172+
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
173+
174+
pseudoxml:
175+
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
176+
@echo
177+
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. osxpython documentation master file, created by
1+
.. pythonguide documentation master file, created by
22
sphinx-quickstart on Wed Aug 4 22:51:11 2010.
33
You can adapt this file completely to your liking, but it should at least
44
contain the root `toctree` directive.

docs/make.bat

Lines changed: 100 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ if "%SPHINXBUILD%" == "" (
77
)
88
set BUILDDIR=_build
99
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
10+
set I18NSPHINXOPTS=%SPHINXOPTS% .
1011
if NOT "%PAPER%" == "" (
1112
set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
13+
set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
1214
)
1315

1416
if "%1" == "" goto help
@@ -28,7 +30,11 @@ if "%1" == "help" (
2830
echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter
2931
echo. text to make text files
3032
echo. man to make manual pages
33+
echo. texinfo to make Texinfo files
34+
echo. gettext to make PO message catalogs
3135
echo. changes to make an overview over all changed/added/deprecated items
36+
echo. xml to make Docutils-native XML files
37+
echo. pseudoxml to make pseudoxml-XML files for display purposes
3238
echo. linkcheck to check all external links for integrity
3339
echo. doctest to run all doctests embedded in the documentation if enabled
3440
goto end
@@ -40,43 +46,74 @@ if "%1" == "clean" (
4046
goto end
4147
)
4248

49+
50+
REM Check if sphinx-build is available and fallback to Python version if any
51+
%SPHINXBUILD% 2> nul
52+
if errorlevel 9009 goto sphinx_python
53+
goto sphinx_ok
54+
55+
:sphinx_python
56+
57+
set SPHINXBUILD=python -m sphinx.__init__
58+
%SPHINXBUILD% 2> nul
59+
if errorlevel 9009 (
60+
echo.
61+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
62+
echo.installed, then set the SPHINXBUILD environment variable to point
63+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
64+
echo.may add the Sphinx directory to PATH.
65+
echo.
66+
echo.If you don't have Sphinx installed, grab it from
67+
echo.http://sphinx-doc.org/
68+
exit /b 1
69+
)
70+
71+
:sphinx_ok
72+
73+
4374
if "%1" == "html" (
4475
%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
76+
if errorlevel 1 exit /b 1
4577
echo.
4678
echo.Build finished. The HTML pages are in %BUILDDIR%/html.
4779
goto end
4880
)
4981

5082
if "%1" == "dirhtml" (
5183
%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
84+
if errorlevel 1 exit /b 1
5285
echo.
5386
echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
5487
goto end
5588
)
5689

5790
if "%1" == "singlehtml" (
5891
%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
92+
if errorlevel 1 exit /b 1
5993
echo.
6094
echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
6195
goto end
6296
)
6397

6498
if "%1" == "pickle" (
6599
%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
100+
if errorlevel 1 exit /b 1
66101
echo.
67102
echo.Build finished; now you can process the pickle files.
68103
goto end
69104
)
70105

71106
if "%1" == "json" (
72107
%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
108+
if errorlevel 1 exit /b 1
73109
echo.
74110
echo.Build finished; now you can process the JSON files.
75111
goto end
76112
)
77113

78114
if "%1" == "htmlhelp" (
79115
%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
116+
if errorlevel 1 exit /b 1
80117
echo.
81118
echo.Build finished; now you can run HTML Help Workshop with the ^
82119
.hhp project file in %BUILDDIR%/htmlhelp.
@@ -85,59 +122,103 @@ if "%1" == "htmlhelp" (
85122

86123
if "%1" == "qthelp" (
87124
%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
125+
if errorlevel 1 exit /b 1
88126
echo.
89127
echo.Build finished; now you can run "qcollectiongenerator" with the ^
90128
.qhcp project file in %BUILDDIR%/qthelp, like this:
91-
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\osxpython.qhcp
129+
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\pythonguide.qhcp
92130
echo.To view the help file:
93-
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\osxpython.ghc
131+
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\pythonguide.ghc
94132
goto end
95133
)
96134

97135
if "%1" == "devhelp" (
98136
%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
137+
if errorlevel 1 exit /b 1
99138
echo.
100139
echo.Build finished.
101140
goto end
102141
)
103142

104143
if "%1" == "epub" (
105144
%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
145+
if errorlevel 1 exit /b 1
106146
echo.
107147
echo.Build finished. The epub file is in %BUILDDIR%/epub.
108148
goto end
109149
)
110150

111151
if "%1" == "latex" (
112152
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
153+
if errorlevel 1 exit /b 1
113154
echo.
114155
echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
115156
goto end
116157
)
117158

159+
if "%1" == "latexpdf" (
160+
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
161+
cd %BUILDDIR%/latex
162+
make all-pdf
163+
cd %BUILDDIR%/..
164+
echo.
165+
echo.Build finished; the PDF files are in %BUILDDIR%/latex.
166+
goto end
167+
)
168+
169+
if "%1" == "latexpdfja" (
170+
%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
171+
cd %BUILDDIR%/latex
172+
make all-pdf-ja
173+
cd %BUILDDIR%/..
174+
echo.
175+
echo.Build finished; the PDF files are in %BUILDDIR%/latex.
176+
goto end
177+
)
178+
118179
if "%1" == "text" (
119180
%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
181+
if errorlevel 1 exit /b 1
120182
echo.
121183
echo.Build finished. The text files are in %BUILDDIR%/text.
122184
goto end
123185
)
124186

125187
if "%1" == "man" (
126188
%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
189+
if errorlevel 1 exit /b 1
127190
echo.
128191
echo.Build finished. The manual pages are in %BUILDDIR%/man.
129192
goto end
130193
)
131194

195+
if "%1" == "texinfo" (
196+
%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
197+
if errorlevel 1 exit /b 1
198+
echo.
199+
echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
200+
goto end
201+
)
202+
203+
if "%1" == "gettext" (
204+
%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
205+
if errorlevel 1 exit /b 1
206+
echo.
207+
echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
208+
goto end
209+
)
210+
132211
if "%1" == "changes" (
133212
%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
213+
if errorlevel 1 exit /b 1
134214
echo.
135215
echo.The overview file is in %BUILDDIR%/changes.
136216
goto end
137217
)
138218

139219
if "%1" == "linkcheck" (
140220
%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
221+
if errorlevel 1 exit /b 1
141222
echo.
142223
echo.Link check complete; look for any errors in the above output ^
143224
or in %BUILDDIR%/linkcheck/output.txt.
@@ -146,10 +227,27 @@ or in %BUILDDIR%/linkcheck/output.txt.
146227

147228
if "%1" == "doctest" (
148229
%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
230+
if errorlevel 1 exit /b 1
149231
echo.
150232
echo.Testing of doctests in the sources finished, look at the ^
151233
results in %BUILDDIR%/doctest/output.txt.
152234
goto end
153235
)
154236

237+
if "%1" == "xml" (
238+
%SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml
239+
if errorlevel 1 exit /b 1
240+
echo.
241+
echo.Build finished. The XML files are in %BUILDDIR%/xml.
242+
goto end
243+
)
244+
245+
if "%1" == "pseudoxml" (
246+
%SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml
247+
if errorlevel 1 exit /b 1
248+
echo.
249+
echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml.
250+
goto end
251+
)
252+
155253
:end

0 commit comments

Comments
 (0)