blob: 2220d92d91ceab4a58f40fa414e0247c161cbe71 [file] [log] [blame]
Georg Brandl116aa622007-08-15 14:28:22 +00001#
2# Makefile for Python documentation
3# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4#
5
6# You can set these variables from the command line.
Benjamin Peterson62f71b02009-03-03 22:55:55 +00007PYTHON = python
Georg Brandlf7b2f362014-02-16 09:46:36 +01008SPHINXBUILD = sphinx-build
Christian Heimes2c181612007-12-17 20:04:13 +00009PAPER =
Christian Heimesfe337bf2008-03-23 21:54:12 +000010SOURCES =
Benjamin Peterson82c05a52014-12-10 11:04:17 -050011DISTVERSION = $(shell $(PYTHON) tools/extensions/patchlevel.py)
Georg Brandl116aa622007-08-15 14:28:22 +000012
Christian Heimes2c181612007-12-17 20:04:13 +000013ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees -D latex_paper_size=$(PAPER) \
Christian Heimesfe337bf2008-03-23 21:54:12 +000014 $(SPHINXOPTS) . build/$(BUILDER) $(SOURCES)
Georg Brandl116aa622007-08-15 14:28:22 +000015
Éric Araujof446d7a2014-03-13 19:30:43 -040016.PHONY: help build html htmlhelp latex text changes linkcheck \
Georg Brandlfe427fe2010-03-13 11:02:07 +000017 suspicious coverage doctest pydoc-topics htmlview clean dist check serve \
18 autobuild-dev autobuild-stable
Georg Brandl116aa622007-08-15 14:28:22 +000019
20help:
21 @echo "Please use \`make <target>' where <target> is one of"
Georg Brandlfe427fe2010-03-13 11:02:07 +000022 @echo " clean to remove build files"
Georg Brandlfe427fe2010-03-13 11:02:07 +000023 @echo " html to make standalone HTML files"
Zachary Ware9393fff2014-04-29 09:24:40 -050024 @echo " htmlview to open the index page built by the html target in your browser"
Georg Brandlfe427fe2010-03-13 11:02:07 +000025 @echo " htmlhelp to make HTML files and a HTML help project"
26 @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
27 @echo " text to make plain text files"
Georg Brandl183fe812011-01-05 11:00:25 +000028 @echo " epub to make EPUB files"
Georg Brandlfe427fe2010-03-13 11:02:07 +000029 @echo " changes to make an overview over all changed/added/deprecated items"
30 @echo " linkcheck to check all external links for integrity"
31 @echo " coverage to check documentation coverage for library and C API"
32 @echo " doctest to run doctests in the documentation"
33 @echo " pydoc-topics to regenerate the pydoc topics file"
34 @echo " dist to create a \"dist\" directory with archived docs for download"
Benjamin Peterson28d88b42009-01-09 03:03:23 +000035 @echo " suspicious to check for suspicious markup in output text"
Georg Brandlfe427fe2010-03-13 11:02:07 +000036 @echo " check to run a check for frequent markup errors"
37 @echo " serve to serve the documentation on the localhost (8000)"
Georg Brandl116aa622007-08-15 14:28:22 +000038
Éric Araujof446d7a2014-03-13 19:30:43 -040039build:
Georg Brandlf7b2f362014-02-16 09:46:36 +010040 $(SPHINXBUILD) $(ALLSPHINXOPTS)
Georg Brandl116aa622007-08-15 14:28:22 +000041 @echo
42
43html: BUILDER = html
44html: build
45 @echo "Build finished. The HTML pages are in build/html."
46
Georg Brandl116aa622007-08-15 14:28:22 +000047htmlhelp: BUILDER = htmlhelp
48htmlhelp: build
49 @echo "Build finished; now you can run HTML Help Workshop with the" \
Guido van Rossumda27fd22007-08-17 00:24:54 +000050 "build/htmlhelp/pydoc.hhp project file."
Georg Brandl116aa622007-08-15 14:28:22 +000051
Christian Heimesd8654cf2007-12-02 15:22:16 +000052latex: BUILDER = latex
53latex: build
54 @echo "Build finished; the LaTeX files are in build/latex."
Christian Heimes2c181612007-12-17 20:04:13 +000055 @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
56 "run these through (pdf)latex."
Christian Heimesd8654cf2007-12-02 15:22:16 +000057
Georg Brandl0c77a822008-06-10 16:37:50 +000058text: BUILDER = text
59text: build
60 @echo "Build finished; the text files are in build/text."
61
Georg Brandl183fe812011-01-05 11:00:25 +000062epub: BUILDER = epub
63epub: build
64 @echo "Build finished; the epub files are in build/epub."
65
Christian Heimes5b5e81c2007-12-31 16:14:33 +000066changes: BUILDER = changes
67changes: build
68 @echo "The overview file is in build/changes."
69
Christian Heimes292d3512008-02-03 16:51:08 +000070linkcheck: BUILDER = linkcheck
Serhiy Storchaka17f5f812014-07-22 10:24:25 +030071linkcheck:
72 @$(MAKE) build BUILDER=$(BUILDER) || { \
73 echo "Link check complete; look for any errors in the above output" \
74 "or in build/$(BUILDER)/output.txt"; \
75 false; }
Christian Heimes292d3512008-02-03 16:51:08 +000076
Benjamin Peterson28d88b42009-01-09 03:03:23 +000077suspicious: BUILDER = suspicious
Serhiy Storchaka17f5f812014-07-22 10:24:25 +030078suspicious:
79 @$(MAKE) build BUILDER=$(BUILDER) || { \
80 echo "Suspicious check complete; look for any errors in the above output" \
81 "or in build/$(BUILDER)/suspicious.csv. If all issues are false" \
Georg Brandl97e9ec62014-09-30 22:51:30 +020082 "positives, append that file to tools/susp-ignored.csv."; \
Serhiy Storchaka17f5f812014-07-22 10:24:25 +030083 false; }
Benjamin Peterson28d88b42009-01-09 03:03:23 +000084
Christian Heimesd3eb5a152008-02-24 00:38:49 +000085coverage: BUILDER = coverage
86coverage: build
87 @echo "Coverage finished; see c.txt and python.txt in build/coverage"
88
Christian Heimesfe337bf2008-03-23 21:54:12 +000089doctest: BUILDER = doctest
Serhiy Storchaka17f5f812014-07-22 10:24:25 +030090doctest:
91 @$(MAKE) build BUILDER=$(BUILDER) || { \
92 echo "Testing of doctests in the sources finished, look at the" \
93 "results in build/doctest/output.txt"; \
94 false; }
Christian Heimesfe337bf2008-03-23 21:54:12 +000095
Georg Brandl6b38daa2008-06-01 21:05:17 +000096pydoc-topics: BUILDER = pydoc-topics
97pydoc-topics: build
Georg Brandl19b3e002010-10-06 10:35:24 +000098 @echo "Building finished; now copy build/pydoc-topics/topics.py" \
Georg Brandl7f3cd982011-07-03 09:30:42 +020099 "to ../Lib/pydoc_data/topics.py"
Georg Brandl6b38daa2008-06-01 21:05:17 +0000100
Benjamin Peterson41181742008-07-02 20:22:54 +0000101htmlview: html
102 $(PYTHON) -c "import webbrowser; webbrowser.open('build/html/index.html')"
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000103
Georg Brandl116aa622007-08-15 14:28:22 +0000104clean:
105 -rm -rf build/*
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000106
107dist:
Georg Brandl38557f22010-08-03 12:36:57 +0000108 rm -rf dist
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000109 mkdir -p dist
110
111 # archive the HTML
112 make html
Benjamin Peterson92035012008-12-27 16:00:54 +0000113 cp -pPR build/html dist/python-$(DISTVERSION)-docs-html
114 tar -C dist -cf dist/python-$(DISTVERSION)-docs-html.tar python-$(DISTVERSION)-docs-html
115 bzip2 -9 -k dist/python-$(DISTVERSION)-docs-html.tar
116 (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-html.zip python-$(DISTVERSION)-docs-html)
117 rm -r dist/python-$(DISTVERSION)-docs-html
118 rm dist/python-$(DISTVERSION)-docs-html.tar
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000119
120 # archive the text build
121 make text
Benjamin Peterson92035012008-12-27 16:00:54 +0000122 cp -pPR build/text dist/python-$(DISTVERSION)-docs-text
123 tar -C dist -cf dist/python-$(DISTVERSION)-docs-text.tar python-$(DISTVERSION)-docs-text
124 bzip2 -9 -k dist/python-$(DISTVERSION)-docs-text.tar
125 (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-text.zip python-$(DISTVERSION)-docs-text)
126 rm -r dist/python-$(DISTVERSION)-docs-text
127 rm dist/python-$(DISTVERSION)-docs-text.tar
Georg Brandl5617db82009-04-27 16:28:57 +0000128
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000129 # archive the A4 latex
Georg Brandl38557f22010-08-03 12:36:57 +0000130 rm -rf build/latex
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000131 make latex PAPER=a4
Georg Brandl692b3f82010-07-11 08:33:16 +0000132 -sed -i 's/makeindex/makeindex -q/' build/latex/Makefile
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000133 (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Peterson92035012008-12-27 16:00:54 +0000134 cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-a4.zip
135 cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-a4.tar.bz2
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000136
137 # archive the letter latex
Georg Brandl38557f22010-08-03 12:36:57 +0000138 rm -rf build/latex
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000139 make latex PAPER=letter
Georg Brandl692b3f82010-07-11 08:33:16 +0000140 -sed -i 's/makeindex/makeindex -q/' build/latex/Makefile
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000141 (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Peterson92035012008-12-27 16:00:54 +0000142 cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-letter.zip
143 cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-letter.tar.bz2
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000144
Georg Brandl865bdbf2014-03-28 19:48:55 +0100145 # copy the epub build
Georg Brandl183fe812011-01-05 11:00:25 +0000146 rm -rf build/epub
147 make epub
Georg Brandl865bdbf2014-03-28 19:48:55 +0100148 cp -pPR build/epub/Python.epub dist/python-$(DISTVERSION)-docs.epub
Georg Brandl183fe812011-01-05 11:00:25 +0000149
Georg Brandl45f53372009-01-03 21:15:20 +0000150check:
Georg Brandld5097882009-01-03 21:30:40 +0000151 $(PYTHON) tools/rstlint.py -i tools
R. David Murraye821cb62010-03-08 17:48:38 +0000152
153serve:
154 ../Tools/scripts/serve.py build/html
Georg Brandlfe427fe2010-03-13 11:02:07 +0000155
Georg Brandl49f47182010-03-13 13:42:16 +0000156# Targets for daily automated doc build
Georg Brandlfe427fe2010-03-13 11:02:07 +0000157
158# for development releases: always build
159autobuild-dev:
Ezio Melotti58864b32012-10-27 22:28:48 +0300160 make dist SPHINXOPTS='-A daily=1 -A versionswitcher=1'
Georg Brandl44d24292013-11-24 16:17:54 +0100161 -make suspicious
Georg Brandlfe427fe2010-03-13 11:02:07 +0000162
Georg Brandl01f47e82012-10-28 08:09:02 +0100163# for quick rebuilds (HTML only)
Georg Brandl4b9e75b2016-06-15 08:57:32 +0200164autobuild-dev-html:
Georg Brandl01f47e82012-10-28 08:09:02 +0100165 make html SPHINXOPTS='-A daily=1 -A versionswitcher=1'
166
Benjamin Petersonefd713b2014-09-24 20:22:24 -0400167# for stable releases: only build if not in pre-release stage (alpha, beta)
168# release candidate downloads are okay, since the stable tree can be in that stage
Georg Brandlfe427fe2010-03-13 11:02:07 +0000169autobuild-stable:
Benjamin Petersonefd713b2014-09-24 20:22:24 -0400170 @case $(DISTVERSION) in *[ab]*) \
Georg Brandl49f47182010-03-13 13:42:16 +0000171 echo "Not building; $(DISTVERSION) is not a release version."; \
172 exit 1;; \
Georg Brandlfe427fe2010-03-13 11:02:07 +0000173 esac
174 @make autobuild-dev
Georg Brandl01f47e82012-10-28 08:09:02 +0100175
Georg Brandl4b9e75b2016-06-15 08:57:32 +0200176autobuild-stable-html:
177 @case $(DISTVERSION) in *[ab]*) \
178 echo "Not building; $(DISTVERSION) is not a release version."; \
179 exit 1;; \
180 esac
181 @make autobuild-dev-html