blob: f653d70674eb1c6565c41c2f2b0dc66cac214599 [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)
Julien Palardf98c1622018-11-03 19:06:33 +010014SPHINXERRORHANDLING = -W
Georg Brandl116aa622007-08-15 14:28:22 +000015
Jean-François Bb5381f62019-09-09 23:52:03 +020016# Internal variables.
17PAPEROPT_a4 = -D latex_elements.papersize=a4paper
18PAPEROPT_letter = -D latex_elements.papersize=letterpaper
19
20ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees $(PAPEROPT_$(PAPER)) \
Julien Palardf98c1622018-11-03 19:06:33 +010021 $(SPHINXOPTS) $(SPHINXERRORHANDLING) . build/$(BUILDER) $(SOURCES)
Georg Brandl116aa622007-08-15 14:28:22 +000022
Dmitry Shachnevc3d679f2019-09-10 17:40:50 +030023.PHONY: help build html htmlhelp latex text texinfo changes linkcheck \
Georg Brandlfe427fe2010-03-13 11:02:07 +000024suspicious coverage doctest pydoc-topics htmlview clean dist check serve \
Ned Deily122fc132017-11-27 17:07:32 -050025autobuild-dev autobuild-stable venv
Georg Brandl116aa622007-08-15 14:28:22 +000026
27help:
28@echo "Please use \`make <target>' where <target> is one of"
Georg Brandlfe427fe2010-03-13 11:02:07 +000029@echo " clean to remove build files"
Brett Cannond5ea39d2014-12-05 15:17:31 -050030@echo " venv to create a venv with necessary tools"
Georg Brandlfe427fe2010-03-13 11:02:07 +000031@echo " html to make standalone HTML files"
Zachary Ware9393fff2014-04-29 09:24:40 -050032@echo " htmlview to open the index page built by the html target in your browser"
Georg Brandlfe427fe2010-03-13 11:02:07 +000033@echo " htmlhelp to make HTML files and a HTML help project"
34@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
35@echo " text to make plain text files"
Dmitry Shachnevc3d679f2019-09-10 17:40:50 +030036@echo " texinfo to make Texinfo file"
Georg Brandl183fe812011-01-05 11:00:25 +000037@echo " epub to make EPUB files"
Georg Brandlfe427fe2010-03-13 11:02:07 +000038@echo " changes to make an overview over all changed/added/deprecated items"
39@echo " linkcheck to check all external links for integrity"
40@echo " coverage to check documentation coverage for library and C API"
41@echo " doctest to run doctests in the documentation"
42@echo " pydoc-topics to regenerate the pydoc topics file"
43@echo " dist to create a \"dist\" directory with archived docs for download"
Benjamin Peterson28d88b42009-01-09 03:03:23 +000044@echo " suspicious to check for suspicious markup in output text"
Georg Brandlfe427fe2010-03-13 11:02:07 +000045@echo " check to run a check for frequent markup errors"
46@echo " serve to serve the documentation on the localhost (8000)"
Georg Brandl116aa622007-08-15 14:28:22 +000047
Ned Deily122fc132017-11-27 17:07:32 -050048build:
Ned Deilyfcd97d42017-09-05 00:10:31 -070049-mkdir -p build
50# Look first for a Misc/NEWS file (building from a source release tarball
51# or old repo) and use that, otherwise look for a Misc/NEWS.d directory
52# (building from a newer repo) and use blurb to generate the NEWS file.
53@if [ -f ../Misc/NEWS ] ; then \
54echo "Using existing Misc/NEWS file"; \
55cp ../Misc/NEWS build/NEWS; \
Gregory P. Smith3918ad62019-05-07 17:03:50 -040056elif $(BLURB) help >/dev/null 2>&1 && $(SPHINXBUILD) --version >/dev/null 2>&1; then \
57if [ -d ../Misc/NEWS.d ]; then \
58echo "Building NEWS from Misc/NEWS.d with blurb"; \
59$(BLURB) merge -f build/NEWS; \
60else \
61echo "Neither Misc/NEWS.d nor Misc/NEWS found; cannot build docs"; \
62exit 1; \
63fi \
Ned Deilyfcd97d42017-09-05 00:10:31 -070064else \
Gregory P. Smith3918ad62019-05-07 17:03:50 -040065echo ""; \
66echo "Missing the required blurb or sphinx-build tools."; \
67echo "Please run 'make venv' to install local copies."; \
68echo ""; \
Ned Deilyfcd97d42017-09-05 00:10:31 -070069exit 1; \
70fi
Georg Brandlf7b2f362014-02-16 09:46:36 +010071$(SPHINXBUILD) $(ALLSPHINXOPTS)
Georg Brandl116aa622007-08-15 14:28:22 +000072@echo
73
74html: BUILDER = html
75html: build
76@echo "Build finished. The HTML pages are in build/html."
77
Georg Brandl116aa622007-08-15 14:28:22 +000078htmlhelp: BUILDER = htmlhelp
79htmlhelp: build
80@echo "Build finished; now you can run HTML Help Workshop with the" \
Guido van Rossumda27fd22007-08-17 00:24:54 +000081 "build/htmlhelp/pydoc.hhp project file."
Georg Brandl116aa622007-08-15 14:28:22 +000082
Christian Heimesd8654cf2007-12-02 15:22:16 +000083latex: BUILDER = latex
84latex: build
85@echo "Build finished; the LaTeX files are in build/latex."
Christian Heimes2c181612007-12-17 20:04:13 +000086@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
87 "run these through (pdf)latex."
Christian Heimesd8654cf2007-12-02 15:22:16 +000088
Georg Brandl0c77a822008-06-10 16:37:50 +000089text: BUILDER = text
90text: build
91@echo "Build finished; the text files are in build/text."
92
Dmitry Shachnevc3d679f2019-09-10 17:40:50 +030093texinfo: BUILDER = texinfo
94texinfo: build
95@echo "Build finished; the python.texi file is in build/texinfo."
96@echo "Run \`make info' in that directory to run it through makeinfo."
97
Georg Brandl183fe812011-01-05 11:00:25 +000098epub: BUILDER = epub
99epub: build
100@echo "Build finished; the epub files are in build/epub."
101
Christian Heimes5b5e81c2007-12-31 16:14:33 +0000102changes: BUILDER = changes
103changes: build
104@echo "The overview file is in build/changes."
105
Christian Heimes292d3512008-02-03 16:51:08 +0000106linkcheck: BUILDER = linkcheck
Serhiy Storchaka17f5f812014-07-22 10:24:25 +0300107linkcheck:
108@$(MAKE) build BUILDER=$(BUILDER) || { \
109echo "Link check complete; look for any errors in the above output" \
110 "or in build/$(BUILDER)/output.txt"; \
111false; }
Christian Heimes292d3512008-02-03 16:51:08 +0000112
Benjamin Peterson28d88b42009-01-09 03:03:23 +0000113suspicious: BUILDER = suspicious
Serhiy Storchaka17f5f812014-07-22 10:24:25 +0300114suspicious:
115@$(MAKE) build BUILDER=$(BUILDER) || { \
116echo "Suspicious check complete; look for any errors in the above output" \
117 "or in build/$(BUILDER)/suspicious.csv. If all issues are false" \
Georg Brandl61bd1dc2014-09-30 22:56:38 +0200118 "positives, append that file to tools/susp-ignored.csv."; \
Serhiy Storchaka17f5f812014-07-22 10:24:25 +0300119false; }
Benjamin Peterson28d88b42009-01-09 03:03:23 +0000120
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000121coverage: BUILDER = coverage
122coverage: build
123@echo "Coverage finished; see c.txt and python.txt in build/coverage"
124
Christian Heimesfe337bf2008-03-23 21:54:12 +0000125doctest: BUILDER = doctest
Serhiy Storchaka17f5f812014-07-22 10:24:25 +0300126doctest:
127@$(MAKE) build BUILDER=$(BUILDER) || { \
128echo "Testing of doctests in the sources finished, look at the" \
129 "results in build/doctest/output.txt"; \
130false; }
Christian Heimesfe337bf2008-03-23 21:54:12 +0000131
Georg Brandl6b38daa2008-06-01 21:05:17 +0000132pydoc-topics: BUILDER = pydoc-topics
133pydoc-topics: build
Larry Hastingse8ff0ca2015-05-30 16:58:27 -0700134@echo "Building finished; now run this:" \
135 "cp build/pydoc-topics/topics.py ../Lib/pydoc_data/topics.py"
Georg Brandl6b38daa2008-06-01 21:05:17 +0000136
Benjamin Peterson41181742008-07-02 20:22:54 +0000137htmlview: html
138 $(PYTHON) -c "import webbrowser; webbrowser.open('build/html/index.html')"
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000139
Georg Brandl116aa622007-08-15 14:28:22 +0000140clean:
Ned Deily590665c2017-09-07 17:17:53 -0700141-rm -rf build/* $(VENVDIR)/*
Brett Cannond5ea39d2014-12-05 15:17:31 -0500142
143venv:
Ned Deily122fc132017-11-27 17:07:32 -0500144$(PYTHON) -m venv $(VENVDIR)
Stéphane Wirtel0a52d732019-05-14 13:49:49 +0200145$(VENVDIR)/bin/python3 -m pip install -U pip setuptools
Victor Stinner9e73cac2020-09-18 16:53:46 +0200146$(VENVDIR)/bin/python3 -m pip install -r requirements.txt
Ned Deily122fc132017-11-27 17:07:32 -0500147@echo "The venv has been created in the $(VENVDIR) directory"
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000148
149dist:
Georg Brandl38557f22010-08-03 12:36:57 +0000150rm -rf dist
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000151mkdir -p dist
152
153# archive the HTML
154make html
Benjamin Peterson92035012008-12-27 16:00:54 +0000155cp -pPR build/html dist/python-$(DISTVERSION)-docs-html
156tar -C dist -cf dist/python-$(DISTVERSION)-docs-html.tar python-$(DISTVERSION)-docs-html
157bzip2 -9 -k dist/python-$(DISTVERSION)-docs-html.tar
158(cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-html.zip python-$(DISTVERSION)-docs-html)
159rm -r dist/python-$(DISTVERSION)-docs-html
160rm dist/python-$(DISTVERSION)-docs-html.tar
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000161
162# archive the text build
163make text
Benjamin Peterson92035012008-12-27 16:00:54 +0000164cp -pPR build/text dist/python-$(DISTVERSION)-docs-text
165tar -C dist -cf dist/python-$(DISTVERSION)-docs-text.tar python-$(DISTVERSION)-docs-text
166bzip2 -9 -k dist/python-$(DISTVERSION)-docs-text.tar
167(cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-text.zip python-$(DISTVERSION)-docs-text)
168rm -r dist/python-$(DISTVERSION)-docs-text
169rm dist/python-$(DISTVERSION)-docs-text.tar
Georg Brandl5617db82009-04-27 16:28:57 +0000170
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000171# archive the A4 latex
Georg Brandl38557f22010-08-03 12:36:57 +0000172rm -rf build/latex
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000173make latex PAPER=a4
Georg Brandl692b3f82010-07-11 08:33:16 +0000174-sed -i 's/makeindex/makeindex -q/' build/latex/Makefile
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000175(cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Peterson92035012008-12-27 16:00:54 +0000176cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-a4.zip
177cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-a4.tar.bz2
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000178
179# archive the letter latex
Georg Brandl38557f22010-08-03 12:36:57 +0000180rm -rf build/latex
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000181make latex PAPER=letter
Georg Brandl692b3f82010-07-11 08:33:16 +0000182-sed -i 's/makeindex/makeindex -q/' build/latex/Makefile
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000183(cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Peterson92035012008-12-27 16:00:54 +0000184cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-letter.zip
185cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-letter.tar.bz2
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000186
Georg Brandl865bdbf2014-03-28 19:48:55 +0100187# copy the epub build
Georg Brandl183fe812011-01-05 11:00:25 +0000188rm -rf build/epub
189make epub
Georg Brandl865bdbf2014-03-28 19:48:55 +0100190cp -pPR build/epub/Python.epub dist/python-$(DISTVERSION)-docs.epub
Georg Brandl183fe812011-01-05 11:00:25 +0000191
Dmitry Shachnevc3d679f2019-09-10 17:40:50 +0300192# archive the texinfo build
193rm -rf build/texinfo
194make texinfo
195make info --directory=build/texinfo
196cp -pPR build/texinfo dist/python-$(DISTVERSION)-docs-texinfo
197tar -C dist -cf dist/python-$(DISTVERSION)-docs-texinfo.tar python-$(DISTVERSION)-docs-texinfo
198bzip2 -9 -k dist/python-$(DISTVERSION)-docs-texinfo.tar
199(cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-texinfo.zip python-$(DISTVERSION)-docs-texinfo)
200rm -r dist/python-$(DISTVERSION)-docs-texinfo
201rm dist/python-$(DISTVERSION)-docs-texinfo.tar
202
Georg Brandl45f53372009-01-03 21:15:20 +0000203check:
Ned Deily590665c2017-09-07 17:17:53 -0700204$(PYTHON) tools/rstlint.py -i tools -i $(VENVDIR) -i README.rst
R. David Murraye821cb62010-03-08 17:48:38 +0000205
206serve:
Stéphane Wirtel09a9f172019-03-18 11:47:55 +0100207$(PYTHON) ../Tools/scripts/serve.py build/html
Georg Brandlfe427fe2010-03-13 11:02:07 +0000208
Georg Brandl49f47182010-03-13 13:42:16 +0000209# Targets for daily automated doc build
Nick Coghlan7a82f9c2017-06-02 23:30:57 +1000210# By default, Sphinx only rebuilds pages where the page content has changed.
211# This means it doesn't always pick up changes to preferred link targets, etc
212# To ensure such changes are picked up, we build the published docs with
213# `-E` (to ignore the cached environment) and `-a` (to ignore already existing
214# output files)
Georg Brandlfe427fe2010-03-13 11:02:07 +0000215
216# for development releases: always build
217autobuild-dev:
Juliendff9b5f2017-08-07 10:27:21 +0200218make dist SPHINXOPTS='$(SPHINXOPTS) -Ea -A daily=1 -A switchers=1'
Georg Brandl44d24292013-11-24 16:17:54 +0100219-make suspicious
Georg Brandlfe427fe2010-03-13 11:02:07 +0000220
Georg Brandl01f47e82012-10-28 08:09:02 +0100221# for quick rebuilds (HTML only)
Georg Brandl4b9e75b2016-06-15 08:57:32 +0200222autobuild-dev-html:
Juliendff9b5f2017-08-07 10:27:21 +0200223make html SPHINXOPTS='$(SPHINXOPTS) -Ea -A daily=1 -A switchers=1'
Georg Brandl01f47e82012-10-28 08:09:02 +0100224
Benjamin Petersonefd713b2014-09-24 20:22:24 -0400225# for stable releases: only build if not in pre-release stage (alpha, beta)
226# release candidate downloads are okay, since the stable tree can be in that stage
Georg Brandlfe427fe2010-03-13 11:02:07 +0000227autobuild-stable:
Benjamin Petersonefd713b2014-09-24 20:22:24 -0400228@case $(DISTVERSION) in *[ab]*) \
Georg Brandl49f47182010-03-13 13:42:16 +0000229echo "Not building; $(DISTVERSION) is not a release version."; \
230exit 1;; \
Georg Brandlfe427fe2010-03-13 11:02:07 +0000231esac
232@make autobuild-dev
Georg Brandl01f47e82012-10-28 08:09:02 +0100233
Georg Brandl4b9e75b2016-06-15 08:57:32 +0200234autobuild-stable-html:
235@case $(DISTVERSION) in *[ab]*) \
236echo "Not building; $(DISTVERSION) is not a release version."; \
237exit 1;; \
238esac
239@make autobuild-dev-html