blob: 53877e61329089f878c52938fe10e1bf4cb7ffa7 [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
Julien Palardf98c1622018-11-03 19:06:33 +010016ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees -D latex_elements.papersize=$(PAPER) \
17 $(SPHINXOPTS) $(SPHINXERRORHANDLING) . build/$(BUILDER) $(SOURCES)
Georg Brandl116aa622007-08-15 14:28:22 +000018
Éric Araujof446d7a2014-03-13 19:30:43 -040019.PHONY: help build html htmlhelp latex text changes linkcheck \
Georg Brandlfe427fe2010-03-13 11:02:07 +000020 suspicious coverage doctest pydoc-topics htmlview clean dist check serve \
Ned Deily122fc132017-11-27 17:07:32 -050021 autobuild-dev autobuild-stable venv
Georg Brandl116aa622007-08-15 14:28:22 +000022
23help:
24 @echo "Please use \`make <target>' where <target> is one of"
Georg Brandlfe427fe2010-03-13 11:02:07 +000025 @echo " clean to remove build files"
Brett Cannond5ea39d2014-12-05 15:17:31 -050026 @echo " venv to create a venv with necessary tools"
Georg Brandlfe427fe2010-03-13 11:02:07 +000027 @echo " html to make standalone HTML files"
Zachary Ware9393fff2014-04-29 09:24:40 -050028 @echo " htmlview to open the index page built by the html target in your browser"
Georg Brandlfe427fe2010-03-13 11:02:07 +000029 @echo " htmlhelp to make HTML files and a HTML help project"
30 @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
31 @echo " text to make plain text files"
Georg Brandl183fe812011-01-05 11:00:25 +000032 @echo " epub to make EPUB files"
Georg Brandlfe427fe2010-03-13 11:02:07 +000033 @echo " changes to make an overview over all changed/added/deprecated items"
34 @echo " linkcheck to check all external links for integrity"
35 @echo " coverage to check documentation coverage for library and C API"
36 @echo " doctest to run doctests in the documentation"
37 @echo " pydoc-topics to regenerate the pydoc topics file"
38 @echo " dist to create a \"dist\" directory with archived docs for download"
Benjamin Peterson28d88b42009-01-09 03:03:23 +000039 @echo " suspicious to check for suspicious markup in output text"
Georg Brandlfe427fe2010-03-13 11:02:07 +000040 @echo " check to run a check for frequent markup errors"
41 @echo " serve to serve the documentation on the localhost (8000)"
Georg Brandl116aa622007-08-15 14:28:22 +000042
Ned Deily122fc132017-11-27 17:07:32 -050043build:
Ned Deilyfcd97d42017-09-05 00:10:31 -070044 -mkdir -p build
45# Look first for a Misc/NEWS file (building from a source release tarball
46# or old repo) and use that, otherwise look for a Misc/NEWS.d directory
47# (building from a newer repo) and use blurb to generate the NEWS file.
48 @if [ -f ../Misc/NEWS ] ; then \
49 echo "Using existing Misc/NEWS file"; \
50 cp ../Misc/NEWS build/NEWS; \
51 elif [ -d ../Misc/NEWS.d ]; then \
52 echo "Building NEWS from Misc/NEWS.d with blurb"; \
53 $(BLURB) merge -f build/NEWS; \
54 else \
55 echo "Neither Misc/NEWS.d nor Misc/NEWS found; cannot build docs"; \
56 exit 1; \
57 fi
Georg Brandlf7b2f362014-02-16 09:46:36 +010058 $(SPHINXBUILD) $(ALLSPHINXOPTS)
Georg Brandl116aa622007-08-15 14:28:22 +000059 @echo
60
61html: BUILDER = html
62html: build
63 @echo "Build finished. The HTML pages are in build/html."
64
Georg Brandl116aa622007-08-15 14:28:22 +000065htmlhelp: BUILDER = htmlhelp
66htmlhelp: build
67 @echo "Build finished; now you can run HTML Help Workshop with the" \
Guido van Rossumda27fd22007-08-17 00:24:54 +000068 "build/htmlhelp/pydoc.hhp project file."
Georg Brandl116aa622007-08-15 14:28:22 +000069
Christian Heimesd8654cf2007-12-02 15:22:16 +000070latex: BUILDER = latex
71latex: build
72 @echo "Build finished; the LaTeX files are in build/latex."
Christian Heimes2c181612007-12-17 20:04:13 +000073 @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
74 "run these through (pdf)latex."
Christian Heimesd8654cf2007-12-02 15:22:16 +000075
Georg Brandl0c77a822008-06-10 16:37:50 +000076text: BUILDER = text
77text: build
78 @echo "Build finished; the text files are in build/text."
79
Georg Brandl183fe812011-01-05 11:00:25 +000080epub: BUILDER = epub
81epub: build
82 @echo "Build finished; the epub files are in build/epub."
83
Christian Heimes5b5e81c2007-12-31 16:14:33 +000084changes: BUILDER = changes
85changes: build
86 @echo "The overview file is in build/changes."
87
Christian Heimes292d3512008-02-03 16:51:08 +000088linkcheck: BUILDER = linkcheck
Serhiy Storchaka17f5f812014-07-22 10:24:25 +030089linkcheck:
90 @$(MAKE) build BUILDER=$(BUILDER) || { \
91 echo "Link check complete; look for any errors in the above output" \
92 "or in build/$(BUILDER)/output.txt"; \
93 false; }
Christian Heimes292d3512008-02-03 16:51:08 +000094
Benjamin Peterson28d88b42009-01-09 03:03:23 +000095suspicious: BUILDER = suspicious
Serhiy Storchaka17f5f812014-07-22 10:24:25 +030096suspicious:
97 @$(MAKE) build BUILDER=$(BUILDER) || { \
98 echo "Suspicious check complete; look for any errors in the above output" \
99 "or in build/$(BUILDER)/suspicious.csv. If all issues are false" \
Georg Brandl61bd1dc2014-09-30 22:56:38 +0200100 "positives, append that file to tools/susp-ignored.csv."; \
Serhiy Storchaka17f5f812014-07-22 10:24:25 +0300101 false; }
Benjamin Peterson28d88b42009-01-09 03:03:23 +0000102
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000103coverage: BUILDER = coverage
104coverage: build
105 @echo "Coverage finished; see c.txt and python.txt in build/coverage"
106
Christian Heimesfe337bf2008-03-23 21:54:12 +0000107doctest: BUILDER = doctest
Serhiy Storchaka17f5f812014-07-22 10:24:25 +0300108doctest:
109 @$(MAKE) build BUILDER=$(BUILDER) || { \
110 echo "Testing of doctests in the sources finished, look at the" \
111 "results in build/doctest/output.txt"; \
112 false; }
Christian Heimesfe337bf2008-03-23 21:54:12 +0000113
Georg Brandl6b38daa2008-06-01 21:05:17 +0000114pydoc-topics: BUILDER = pydoc-topics
115pydoc-topics: build
Larry Hastingse8ff0ca2015-05-30 16:58:27 -0700116 @echo "Building finished; now run this:" \
117 "cp build/pydoc-topics/topics.py ../Lib/pydoc_data/topics.py"
Georg Brandl6b38daa2008-06-01 21:05:17 +0000118
Benjamin Peterson41181742008-07-02 20:22:54 +0000119htmlview: html
120 $(PYTHON) -c "import webbrowser; webbrowser.open('build/html/index.html')"
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000121
Georg Brandl116aa622007-08-15 14:28:22 +0000122clean:
Ned Deily590665c2017-09-07 17:17:53 -0700123 -rm -rf build/* $(VENVDIR)/*
Brett Cannond5ea39d2014-12-05 15:17:31 -0500124
125venv:
Ned Deily122fc132017-11-27 17:07:32 -0500126 $(PYTHON) -m venv $(VENVDIR)
Jon Wayne Parrottbf63e8d2018-03-01 13:02:50 -0800127 $(VENVDIR)/bin/python3 -m pip install -U Sphinx blurb python-docs-theme
Ned Deily122fc132017-11-27 17:07:32 -0500128 @echo "The venv has been created in the $(VENVDIR) directory"
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000129
130dist:
Georg Brandl38557f22010-08-03 12:36:57 +0000131 rm -rf dist
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000132 mkdir -p dist
133
134 # archive the HTML
135 make html
Benjamin Peterson92035012008-12-27 16:00:54 +0000136 cp -pPR build/html dist/python-$(DISTVERSION)-docs-html
137 tar -C dist -cf dist/python-$(DISTVERSION)-docs-html.tar python-$(DISTVERSION)-docs-html
138 bzip2 -9 -k dist/python-$(DISTVERSION)-docs-html.tar
139 (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-html.zip python-$(DISTVERSION)-docs-html)
140 rm -r dist/python-$(DISTVERSION)-docs-html
141 rm dist/python-$(DISTVERSION)-docs-html.tar
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000142
143 # archive the text build
144 make text
Benjamin Peterson92035012008-12-27 16:00:54 +0000145 cp -pPR build/text dist/python-$(DISTVERSION)-docs-text
146 tar -C dist -cf dist/python-$(DISTVERSION)-docs-text.tar python-$(DISTVERSION)-docs-text
147 bzip2 -9 -k dist/python-$(DISTVERSION)-docs-text.tar
148 (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-text.zip python-$(DISTVERSION)-docs-text)
149 rm -r dist/python-$(DISTVERSION)-docs-text
150 rm dist/python-$(DISTVERSION)-docs-text.tar
Georg Brandl5617db82009-04-27 16:28:57 +0000151
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000152 # archive the A4 latex
Georg Brandl38557f22010-08-03 12:36:57 +0000153 rm -rf build/latex
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000154 make latex PAPER=a4
Georg Brandl692b3f82010-07-11 08:33:16 +0000155 -sed -i 's/makeindex/makeindex -q/' build/latex/Makefile
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000156 (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Peterson92035012008-12-27 16:00:54 +0000157 cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-a4.zip
158 cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-a4.tar.bz2
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000159
160 # archive the letter latex
Georg Brandl38557f22010-08-03 12:36:57 +0000161 rm -rf build/latex
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000162 make latex PAPER=letter
Georg Brandl692b3f82010-07-11 08:33:16 +0000163 -sed -i 's/makeindex/makeindex -q/' build/latex/Makefile
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000164 (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Peterson92035012008-12-27 16:00:54 +0000165 cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-letter.zip
166 cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-letter.tar.bz2
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000167
Georg Brandl865bdbf2014-03-28 19:48:55 +0100168 # copy the epub build
Georg Brandl183fe812011-01-05 11:00:25 +0000169 rm -rf build/epub
170 make epub
Georg Brandl865bdbf2014-03-28 19:48:55 +0100171 cp -pPR build/epub/Python.epub dist/python-$(DISTVERSION)-docs.epub
Georg Brandl183fe812011-01-05 11:00:25 +0000172
Georg Brandl45f53372009-01-03 21:15:20 +0000173check:
Ned Deily590665c2017-09-07 17:17:53 -0700174 $(PYTHON) tools/rstlint.py -i tools -i $(VENVDIR) -i README.rst
R. David Murraye821cb62010-03-08 17:48:38 +0000175
176serve:
Stéphane Wirtel09a9f172019-03-18 11:47:55 +0100177 $(PYTHON) ../Tools/scripts/serve.py build/html
Georg Brandlfe427fe2010-03-13 11:02:07 +0000178
Georg Brandl49f47182010-03-13 13:42:16 +0000179# Targets for daily automated doc build
Nick Coghlan7a82f9c2017-06-02 23:30:57 +1000180# By default, Sphinx only rebuilds pages where the page content has changed.
181# This means it doesn't always pick up changes to preferred link targets, etc
182# To ensure such changes are picked up, we build the published docs with
183# `-E` (to ignore the cached environment) and `-a` (to ignore already existing
184# output files)
Georg Brandlfe427fe2010-03-13 11:02:07 +0000185
186# for development releases: always build
187autobuild-dev:
Juliendff9b5f2017-08-07 10:27:21 +0200188 make dist SPHINXOPTS='$(SPHINXOPTS) -Ea -A daily=1 -A switchers=1'
Georg Brandl44d24292013-11-24 16:17:54 +0100189 -make suspicious
Georg Brandlfe427fe2010-03-13 11:02:07 +0000190
Georg Brandl01f47e82012-10-28 08:09:02 +0100191# for quick rebuilds (HTML only)
Georg Brandl4b9e75b2016-06-15 08:57:32 +0200192autobuild-dev-html:
Juliendff9b5f2017-08-07 10:27:21 +0200193 make html SPHINXOPTS='$(SPHINXOPTS) -Ea -A daily=1 -A switchers=1'
Georg Brandl01f47e82012-10-28 08:09:02 +0100194
Benjamin Petersonefd713b2014-09-24 20:22:24 -0400195# for stable releases: only build if not in pre-release stage (alpha, beta)
196# release candidate downloads are okay, since the stable tree can be in that stage
Georg Brandlfe427fe2010-03-13 11:02:07 +0000197autobuild-stable:
Benjamin Petersonefd713b2014-09-24 20:22:24 -0400198 @case $(DISTVERSION) in *[ab]*) \
Georg Brandl49f47182010-03-13 13:42:16 +0000199 echo "Not building; $(DISTVERSION) is not a release version."; \
200 exit 1;; \
Georg Brandlfe427fe2010-03-13 11:02:07 +0000201 esac
202 @make autobuild-dev
Georg Brandl01f47e82012-10-28 08:09:02 +0100203
Georg Brandl4b9e75b2016-06-15 08:57:32 +0200204autobuild-stable-html:
205 @case $(DISTVERSION) in *[ab]*) \
206 echo "Not building; $(DISTVERSION) is not a release version."; \
207 exit 1;; \
208 esac
209 @make autobuild-dev-html