blob: 307d1e0e7de10b0a2b9d98c68339b93f02f59122 [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.
Victor Stinner91b0e7d2017-02-15 23:36:08 +01007PYTHON = python3
Ned Deily590665c2017-09-07 17:17:53 -07008VENVDIR = ./venv
9SPHINXBUILD = PATH=$(VENVDIR)/bin:$$PATH sphinx-build
10BLURB = PATH=$(VENVDIR)/bin:$$PATH blurb
Christian Heimes2c181612007-12-17 20:04:13 +000011PAPER =
Christian Heimesfe337bf2008-03-23 21:54:12 +000012SOURCES =
Benjamin Peterson82c05a52014-12-10 11:04:17 -050013DISTVERSION = $(shell $(PYTHON) tools/extensions/patchlevel.py)
Georg Brandl116aa622007-08-15 14:28:22 +000014
Ryan Gonzaleze7ffb992017-02-10 22:47:37 -060015ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees -D latex_elements.papersize=$(PAPER) \
Christian Heimesfe337bf2008-03-23 21:54:12 +000016 $(SPHINXOPTS) . build/$(BUILDER) $(SOURCES)
Georg Brandl116aa622007-08-15 14:28:22 +000017
Éric Araujof446d7a2014-03-13 19:30:43 -040018.PHONY: help build html htmlhelp latex text changes linkcheck \
Georg Brandlfe427fe2010-03-13 11:02:07 +000019 suspicious coverage doctest pydoc-topics htmlview clean dist check serve \
Ned Deily122fc132017-11-27 17:07:32 -050020 autobuild-dev autobuild-stable venv
Georg Brandl116aa622007-08-15 14:28:22 +000021
22help:
23 @echo "Please use \`make <target>' where <target> is one of"
Georg Brandlfe427fe2010-03-13 11:02:07 +000024 @echo " clean to remove build files"
Brett Cannond5ea39d2014-12-05 15:17:31 -050025 @echo " venv to create a venv with necessary tools"
Georg Brandlfe427fe2010-03-13 11:02:07 +000026 @echo " html to make standalone HTML files"
Zachary Ware9393fff2014-04-29 09:24:40 -050027 @echo " htmlview to open the index page built by the html target in your browser"
Georg Brandlfe427fe2010-03-13 11:02:07 +000028 @echo " htmlhelp to make HTML files and a HTML help project"
29 @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
30 @echo " text to make plain text files"
Georg Brandl183fe812011-01-05 11:00:25 +000031 @echo " epub to make EPUB files"
Georg Brandlfe427fe2010-03-13 11:02:07 +000032 @echo " changes to make an overview over all changed/added/deprecated items"
33 @echo " linkcheck to check all external links for integrity"
34 @echo " coverage to check documentation coverage for library and C API"
35 @echo " doctest to run doctests in the documentation"
36 @echo " pydoc-topics to regenerate the pydoc topics file"
37 @echo " dist to create a \"dist\" directory with archived docs for download"
Benjamin Peterson28d88b42009-01-09 03:03:23 +000038 @echo " suspicious to check for suspicious markup in output text"
Georg Brandlfe427fe2010-03-13 11:02:07 +000039 @echo " check to run a check for frequent markup errors"
40 @echo " serve to serve the documentation on the localhost (8000)"
Georg Brandl116aa622007-08-15 14:28:22 +000041
Ned Deily122fc132017-11-27 17:07:32 -050042build:
Ned Deilyfcd97d42017-09-05 00:10:31 -070043 -mkdir -p build
44# Look first for a Misc/NEWS file (building from a source release tarball
45# or old repo) and use that, otherwise look for a Misc/NEWS.d directory
46# (building from a newer repo) and use blurb to generate the NEWS file.
47 @if [ -f ../Misc/NEWS ] ; then \
48 echo "Using existing Misc/NEWS file"; \
49 cp ../Misc/NEWS build/NEWS; \
50 elif [ -d ../Misc/NEWS.d ]; then \
51 echo "Building NEWS from Misc/NEWS.d with blurb"; \
52 $(BLURB) merge -f build/NEWS; \
53 else \
54 echo "Neither Misc/NEWS.d nor Misc/NEWS found; cannot build docs"; \
55 exit 1; \
56 fi
Georg Brandlf7b2f362014-02-16 09:46:36 +010057 $(SPHINXBUILD) $(ALLSPHINXOPTS)
Georg Brandl116aa622007-08-15 14:28:22 +000058 @echo
59
60html: BUILDER = html
61html: build
62 @echo "Build finished. The HTML pages are in build/html."
63
Georg Brandl116aa622007-08-15 14:28:22 +000064htmlhelp: BUILDER = htmlhelp
65htmlhelp: build
66 @echo "Build finished; now you can run HTML Help Workshop with the" \
Guido van Rossumda27fd22007-08-17 00:24:54 +000067 "build/htmlhelp/pydoc.hhp project file."
Georg Brandl116aa622007-08-15 14:28:22 +000068
Christian Heimesd8654cf2007-12-02 15:22:16 +000069latex: BUILDER = latex
70latex: build
71 @echo "Build finished; the LaTeX files are in build/latex."
Christian Heimes2c181612007-12-17 20:04:13 +000072 @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
73 "run these through (pdf)latex."
Christian Heimesd8654cf2007-12-02 15:22:16 +000074
Georg Brandl0c77a822008-06-10 16:37:50 +000075text: BUILDER = text
76text: build
77 @echo "Build finished; the text files are in build/text."
78
Georg Brandl183fe812011-01-05 11:00:25 +000079epub: BUILDER = epub
80epub: build
81 @echo "Build finished; the epub files are in build/epub."
82
Christian Heimes5b5e81c2007-12-31 16:14:33 +000083changes: BUILDER = changes
84changes: build
85 @echo "The overview file is in build/changes."
86
Christian Heimes292d3512008-02-03 16:51:08 +000087linkcheck: BUILDER = linkcheck
Serhiy Storchaka17f5f812014-07-22 10:24:25 +030088linkcheck:
89 @$(MAKE) build BUILDER=$(BUILDER) || { \
90 echo "Link check complete; look for any errors in the above output" \
91 "or in build/$(BUILDER)/output.txt"; \
92 false; }
Christian Heimes292d3512008-02-03 16:51:08 +000093
Benjamin Peterson28d88b42009-01-09 03:03:23 +000094suspicious: BUILDER = suspicious
Serhiy Storchaka17f5f812014-07-22 10:24:25 +030095suspicious:
96 @$(MAKE) build BUILDER=$(BUILDER) || { \
97 echo "Suspicious check complete; look for any errors in the above output" \
98 "or in build/$(BUILDER)/suspicious.csv. If all issues are false" \
Georg Brandl61bd1dc2014-09-30 22:56:38 +020099 "positives, append that file to tools/susp-ignored.csv."; \
Serhiy Storchaka17f5f812014-07-22 10:24:25 +0300100 false; }
Benjamin Peterson28d88b42009-01-09 03:03:23 +0000101
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000102coverage: BUILDER = coverage
103coverage: build
104 @echo "Coverage finished; see c.txt and python.txt in build/coverage"
105
Christian Heimesfe337bf2008-03-23 21:54:12 +0000106doctest: BUILDER = doctest
Serhiy Storchaka17f5f812014-07-22 10:24:25 +0300107doctest:
108 @$(MAKE) build BUILDER=$(BUILDER) || { \
109 echo "Testing of doctests in the sources finished, look at the" \
110 "results in build/doctest/output.txt"; \
111 false; }
Christian Heimesfe337bf2008-03-23 21:54:12 +0000112
Georg Brandl6b38daa2008-06-01 21:05:17 +0000113pydoc-topics: BUILDER = pydoc-topics
114pydoc-topics: build
Larry Hastingse8ff0ca2015-05-30 16:58:27 -0700115 @echo "Building finished; now run this:" \
116 "cp build/pydoc-topics/topics.py ../Lib/pydoc_data/topics.py"
Georg Brandl6b38daa2008-06-01 21:05:17 +0000117
Benjamin Peterson41181742008-07-02 20:22:54 +0000118htmlview: html
119 $(PYTHON) -c "import webbrowser; webbrowser.open('build/html/index.html')"
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000120
Georg Brandl116aa622007-08-15 14:28:22 +0000121clean:
Ned Deily590665c2017-09-07 17:17:53 -0700122 -rm -rf build/* $(VENVDIR)/*
Brett Cannond5ea39d2014-12-05 15:17:31 -0500123
124venv:
Ned Deily122fc132017-11-27 17:07:32 -0500125 $(PYTHON) -m venv $(VENVDIR)
126 $(VENVDIR)/bin/python3 -m pip install -U Sphinx blurb
127 @echo "The venv has been created in the $(VENVDIR) directory"
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000128
129dist:
Georg Brandl38557f22010-08-03 12:36:57 +0000130 rm -rf dist
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000131 mkdir -p dist
132
133 # archive the HTML
134 make html
Benjamin Peterson92035012008-12-27 16:00:54 +0000135 cp -pPR build/html dist/python-$(DISTVERSION)-docs-html
136 tar -C dist -cf dist/python-$(DISTVERSION)-docs-html.tar python-$(DISTVERSION)-docs-html
137 bzip2 -9 -k dist/python-$(DISTVERSION)-docs-html.tar
138 (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-html.zip python-$(DISTVERSION)-docs-html)
139 rm -r dist/python-$(DISTVERSION)-docs-html
140 rm dist/python-$(DISTVERSION)-docs-html.tar
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000141
142 # archive the text build
143 make text
Benjamin Peterson92035012008-12-27 16:00:54 +0000144 cp -pPR build/text dist/python-$(DISTVERSION)-docs-text
145 tar -C dist -cf dist/python-$(DISTVERSION)-docs-text.tar python-$(DISTVERSION)-docs-text
146 bzip2 -9 -k dist/python-$(DISTVERSION)-docs-text.tar
147 (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-text.zip python-$(DISTVERSION)-docs-text)
148 rm -r dist/python-$(DISTVERSION)-docs-text
149 rm dist/python-$(DISTVERSION)-docs-text.tar
Georg Brandl5617db82009-04-27 16:28:57 +0000150
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000151 # archive the A4 latex
Georg Brandl38557f22010-08-03 12:36:57 +0000152 rm -rf build/latex
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000153 make latex PAPER=a4
Georg Brandl692b3f82010-07-11 08:33:16 +0000154 -sed -i 's/makeindex/makeindex -q/' build/latex/Makefile
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000155 (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Peterson92035012008-12-27 16:00:54 +0000156 cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-a4.zip
157 cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-a4.tar.bz2
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000158
159 # archive the letter latex
Georg Brandl38557f22010-08-03 12:36:57 +0000160 rm -rf build/latex
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000161 make latex PAPER=letter
Georg Brandl692b3f82010-07-11 08:33:16 +0000162 -sed -i 's/makeindex/makeindex -q/' build/latex/Makefile
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000163 (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Peterson92035012008-12-27 16:00:54 +0000164 cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-letter.zip
165 cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-letter.tar.bz2
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000166
Georg Brandl865bdbf2014-03-28 19:48:55 +0100167 # copy the epub build
Georg Brandl183fe812011-01-05 11:00:25 +0000168 rm -rf build/epub
169 make epub
Georg Brandl865bdbf2014-03-28 19:48:55 +0100170 cp -pPR build/epub/Python.epub dist/python-$(DISTVERSION)-docs.epub
Georg Brandl183fe812011-01-05 11:00:25 +0000171
Georg Brandl45f53372009-01-03 21:15:20 +0000172check:
Ned Deily590665c2017-09-07 17:17:53 -0700173 $(PYTHON) tools/rstlint.py -i tools -i $(VENVDIR) -i README.rst
R. David Murraye821cb62010-03-08 17:48:38 +0000174
175serve:
176 ../Tools/scripts/serve.py build/html
Georg Brandlfe427fe2010-03-13 11:02:07 +0000177
Georg Brandl49f47182010-03-13 13:42:16 +0000178# Targets for daily automated doc build
Nick Coghlan7a82f9c2017-06-02 23:30:57 +1000179# By default, Sphinx only rebuilds pages where the page content has changed.
180# This means it doesn't always pick up changes to preferred link targets, etc
181# To ensure such changes are picked up, we build the published docs with
182# `-E` (to ignore the cached environment) and `-a` (to ignore already existing
183# output files)
Georg Brandlfe427fe2010-03-13 11:02:07 +0000184
185# for development releases: always build
186autobuild-dev:
Juliendff9b5f2017-08-07 10:27:21 +0200187 make dist SPHINXOPTS='$(SPHINXOPTS) -Ea -A daily=1 -A switchers=1'
Georg Brandl44d24292013-11-24 16:17:54 +0100188 -make suspicious
Georg Brandlfe427fe2010-03-13 11:02:07 +0000189
Georg Brandl01f47e82012-10-28 08:09:02 +0100190# for quick rebuilds (HTML only)
Georg Brandl4b9e75b2016-06-15 08:57:32 +0200191autobuild-dev-html:
Juliendff9b5f2017-08-07 10:27:21 +0200192 make html SPHINXOPTS='$(SPHINXOPTS) -Ea -A daily=1 -A switchers=1'
Georg Brandl01f47e82012-10-28 08:09:02 +0100193
Benjamin Petersonefd713b2014-09-24 20:22:24 -0400194# for stable releases: only build if not in pre-release stage (alpha, beta)
195# release candidate downloads are okay, since the stable tree can be in that stage
Georg Brandlfe427fe2010-03-13 11:02:07 +0000196autobuild-stable:
Benjamin Petersonefd713b2014-09-24 20:22:24 -0400197 @case $(DISTVERSION) in *[ab]*) \
Georg Brandl49f47182010-03-13 13:42:16 +0000198 echo "Not building; $(DISTVERSION) is not a release version."; \
199 exit 1;; \
Georg Brandlfe427fe2010-03-13 11:02:07 +0000200 esac
201 @make autobuild-dev
Georg Brandl01f47e82012-10-28 08:09:02 +0100202
Georg Brandl4b9e75b2016-06-15 08:57:32 +0200203autobuild-stable-html:
204 @case $(DISTVERSION) in *[ab]*) \
205 echo "Not building; $(DISTVERSION) is not a release version."; \
206 exit 1;; \
207 esac
208 @make autobuild-dev-html