blob: 63bbe1d4d71450ee3d157045a2ba412b7c3cfd14 [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
Georg Brandlf7b2f362014-02-16 09:46:36 +01008SPHINXBUILD = sphinx-build
Ned Deilyfcd97d42017-09-05 00:10:31 -07009BLURB = $(PYTHON) -m blurb
Christian Heimes2c181612007-12-17 20:04:13 +000010PAPER =
Christian Heimesfe337bf2008-03-23 21:54:12 +000011SOURCES =
Benjamin Peterson82c05a52014-12-10 11:04:17 -050012DISTVERSION = $(shell $(PYTHON) tools/extensions/patchlevel.py)
Georg Brandl116aa622007-08-15 14:28:22 +000013
Ryan Gonzaleze7ffb992017-02-10 22:47:37 -060014ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees -D latex_elements.papersize=$(PAPER) \
Christian Heimesfe337bf2008-03-23 21:54:12 +000015 $(SPHINXOPTS) . build/$(BUILDER) $(SOURCES)
Georg Brandl116aa622007-08-15 14:28:22 +000016
Éric Araujof446d7a2014-03-13 19:30:43 -040017.PHONY: help build html htmlhelp latex text changes linkcheck \
Georg Brandlfe427fe2010-03-13 11:02:07 +000018 suspicious coverage doctest pydoc-topics htmlview clean dist check serve \
Brett Cannond5ea39d2014-12-05 15:17:31 -050019 autobuild-dev autobuild-stable venv
Georg Brandl116aa622007-08-15 14:28:22 +000020
21help:
22 @echo "Please use \`make <target>' where <target> is one of"
Georg Brandlfe427fe2010-03-13 11:02:07 +000023 @echo " clean to remove build files"
Brett Cannond5ea39d2014-12-05 15:17:31 -050024 @echo " venv to create a venv with necessary tools"
Georg Brandlfe427fe2010-03-13 11:02:07 +000025 @echo " html to make standalone HTML files"
Zachary Ware9393fff2014-04-29 09:24:40 -050026 @echo " htmlview to open the index page built by the html target in your browser"
Georg Brandlfe427fe2010-03-13 11:02:07 +000027 @echo " htmlhelp to make HTML files and a HTML help project"
28 @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
29 @echo " text to make plain text files"
Georg Brandl183fe812011-01-05 11:00:25 +000030 @echo " epub to make EPUB files"
Georg Brandlfe427fe2010-03-13 11:02:07 +000031 @echo " changes to make an overview over all changed/added/deprecated items"
32 @echo " linkcheck to check all external links for integrity"
33 @echo " coverage to check documentation coverage for library and C API"
34 @echo " doctest to run doctests in the documentation"
35 @echo " pydoc-topics to regenerate the pydoc topics file"
36 @echo " dist to create a \"dist\" directory with archived docs for download"
Benjamin Peterson28d88b42009-01-09 03:03:23 +000037 @echo " suspicious to check for suspicious markup in output text"
Georg Brandlfe427fe2010-03-13 11:02:07 +000038 @echo " check to run a check for frequent markup errors"
39 @echo " serve to serve the documentation on the localhost (8000)"
Georg Brandl116aa622007-08-15 14:28:22 +000040
Éric Araujof446d7a2014-03-13 19:30:43 -040041build:
Ned Deilyfcd97d42017-09-05 00:10:31 -070042 -mkdir -p build
43# Look first for a Misc/NEWS file (building from a source release tarball
44# or old repo) and use that, otherwise look for a Misc/NEWS.d directory
45# (building from a newer repo) and use blurb to generate the NEWS file.
46 @if [ -f ../Misc/NEWS ] ; then \
47 echo "Using existing Misc/NEWS file"; \
48 cp ../Misc/NEWS build/NEWS; \
49 elif [ -d ../Misc/NEWS.d ]; then \
50 echo "Building NEWS from Misc/NEWS.d with blurb"; \
51 $(BLURB) merge -f build/NEWS; \
52 else \
53 echo "Neither Misc/NEWS.d nor Misc/NEWS found; cannot build docs"; \
54 exit 1; \
55 fi
Georg Brandlf7b2f362014-02-16 09:46:36 +010056 $(SPHINXBUILD) $(ALLSPHINXOPTS)
Georg Brandl116aa622007-08-15 14:28:22 +000057 @echo
58
59html: BUILDER = html
60html: build
61 @echo "Build finished. The HTML pages are in build/html."
62
Georg Brandl116aa622007-08-15 14:28:22 +000063htmlhelp: BUILDER = htmlhelp
64htmlhelp: build
65 @echo "Build finished; now you can run HTML Help Workshop with the" \
Guido van Rossumda27fd22007-08-17 00:24:54 +000066 "build/htmlhelp/pydoc.hhp project file."
Georg Brandl116aa622007-08-15 14:28:22 +000067
Christian Heimesd8654cf2007-12-02 15:22:16 +000068latex: BUILDER = latex
69latex: build
70 @echo "Build finished; the LaTeX files are in build/latex."
Christian Heimes2c181612007-12-17 20:04:13 +000071 @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
72 "run these through (pdf)latex."
Christian Heimesd8654cf2007-12-02 15:22:16 +000073
Georg Brandl0c77a822008-06-10 16:37:50 +000074text: BUILDER = text
75text: build
76 @echo "Build finished; the text files are in build/text."
77
Georg Brandl183fe812011-01-05 11:00:25 +000078epub: BUILDER = epub
79epub: build
80 @echo "Build finished; the epub files are in build/epub."
81
Christian Heimes5b5e81c2007-12-31 16:14:33 +000082changes: BUILDER = changes
83changes: build
84 @echo "The overview file is in build/changes."
85
Christian Heimes292d3512008-02-03 16:51:08 +000086linkcheck: BUILDER = linkcheck
Serhiy Storchaka17f5f812014-07-22 10:24:25 +030087linkcheck:
88 @$(MAKE) build BUILDER=$(BUILDER) || { \
89 echo "Link check complete; look for any errors in the above output" \
90 "or in build/$(BUILDER)/output.txt"; \
91 false; }
Christian Heimes292d3512008-02-03 16:51:08 +000092
Benjamin Peterson28d88b42009-01-09 03:03:23 +000093suspicious: BUILDER = suspicious
Serhiy Storchaka17f5f812014-07-22 10:24:25 +030094suspicious:
95 @$(MAKE) build BUILDER=$(BUILDER) || { \
96 echo "Suspicious check complete; look for any errors in the above output" \
97 "or in build/$(BUILDER)/suspicious.csv. If all issues are false" \
Georg Brandl61bd1dc2014-09-30 22:56:38 +020098 "positives, append that file to tools/susp-ignored.csv."; \
Serhiy Storchaka17f5f812014-07-22 10:24:25 +030099 false; }
Benjamin Peterson28d88b42009-01-09 03:03:23 +0000100
Christian Heimesd3eb5a152008-02-24 00:38:49 +0000101coverage: BUILDER = coverage
102coverage: build
103 @echo "Coverage finished; see c.txt and python.txt in build/coverage"
104
Christian Heimesfe337bf2008-03-23 21:54:12 +0000105doctest: BUILDER = doctest
Serhiy Storchaka17f5f812014-07-22 10:24:25 +0300106doctest:
107 @$(MAKE) build BUILDER=$(BUILDER) || { \
108 echo "Testing of doctests in the sources finished, look at the" \
109 "results in build/doctest/output.txt"; \
110 false; }
Christian Heimesfe337bf2008-03-23 21:54:12 +0000111
Georg Brandl6b38daa2008-06-01 21:05:17 +0000112pydoc-topics: BUILDER = pydoc-topics
113pydoc-topics: build
Larry Hastingse8ff0ca2015-05-30 16:58:27 -0700114 @echo "Building finished; now run this:" \
115 "cp build/pydoc-topics/topics.py ../Lib/pydoc_data/topics.py"
Georg Brandl6b38daa2008-06-01 21:05:17 +0000116
Benjamin Peterson41181742008-07-02 20:22:54 +0000117htmlview: html
118 $(PYTHON) -c "import webbrowser; webbrowser.open('build/html/index.html')"
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000119
Georg Brandl116aa622007-08-15 14:28:22 +0000120clean:
Brett Cannond5ea39d2014-12-05 15:17:31 -0500121 -rm -rf build/* venv/*
122
123venv:
124 $(PYTHON) -m venv venv
Ned Deilyfcd97d42017-09-05 00:10:31 -0700125 ./venv/bin/python3 -m pip install -U Sphinx blurb
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000126
127dist:
Georg Brandl38557f22010-08-03 12:36:57 +0000128 rm -rf dist
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000129 mkdir -p dist
130
131 # archive the HTML
132 make html
Benjamin Peterson92035012008-12-27 16:00:54 +0000133 cp -pPR build/html dist/python-$(DISTVERSION)-docs-html
134 tar -C dist -cf dist/python-$(DISTVERSION)-docs-html.tar python-$(DISTVERSION)-docs-html
135 bzip2 -9 -k dist/python-$(DISTVERSION)-docs-html.tar
136 (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-html.zip python-$(DISTVERSION)-docs-html)
137 rm -r dist/python-$(DISTVERSION)-docs-html
138 rm dist/python-$(DISTVERSION)-docs-html.tar
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000139
140 # archive the text build
141 make text
Benjamin Peterson92035012008-12-27 16:00:54 +0000142 cp -pPR build/text dist/python-$(DISTVERSION)-docs-text
143 tar -C dist -cf dist/python-$(DISTVERSION)-docs-text.tar python-$(DISTVERSION)-docs-text
144 bzip2 -9 -k dist/python-$(DISTVERSION)-docs-text.tar
145 (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-text.zip python-$(DISTVERSION)-docs-text)
146 rm -r dist/python-$(DISTVERSION)-docs-text
147 rm dist/python-$(DISTVERSION)-docs-text.tar
Georg Brandl5617db82009-04-27 16:28:57 +0000148
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000149 # archive the A4 latex
Georg Brandl38557f22010-08-03 12:36:57 +0000150 rm -rf build/latex
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000151 make latex PAPER=a4
Georg Brandl692b3f82010-07-11 08:33:16 +0000152 -sed -i 's/makeindex/makeindex -q/' build/latex/Makefile
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000153 (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Peterson92035012008-12-27 16:00:54 +0000154 cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-a4.zip
155 cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-a4.tar.bz2
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000156
157 # archive the letter latex
Georg Brandl38557f22010-08-03 12:36:57 +0000158 rm -rf build/latex
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000159 make latex PAPER=letter
Georg Brandl692b3f82010-07-11 08:33:16 +0000160 -sed -i 's/makeindex/makeindex -q/' build/latex/Makefile
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000161 (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Peterson92035012008-12-27 16:00:54 +0000162 cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-letter.zip
163 cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-letter.tar.bz2
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000164
Georg Brandl865bdbf2014-03-28 19:48:55 +0100165 # copy the epub build
Georg Brandl183fe812011-01-05 11:00:25 +0000166 rm -rf build/epub
167 make epub
Georg Brandl865bdbf2014-03-28 19:48:55 +0100168 cp -pPR build/epub/Python.epub dist/python-$(DISTVERSION)-docs.epub
Georg Brandl183fe812011-01-05 11:00:25 +0000169
Georg Brandl45f53372009-01-03 21:15:20 +0000170check:
Rogerb3f1f592017-02-15 17:54:05 -0500171 $(PYTHON) tools/rstlint.py -i tools -i venv -i README.rst
R. David Murraye821cb62010-03-08 17:48:38 +0000172
173serve:
174 ../Tools/scripts/serve.py build/html
Georg Brandlfe427fe2010-03-13 11:02:07 +0000175
Georg Brandl49f47182010-03-13 13:42:16 +0000176# Targets for daily automated doc build
Nick Coghlan7a82f9c2017-06-02 23:30:57 +1000177# By default, Sphinx only rebuilds pages where the page content has changed.
178# This means it doesn't always pick up changes to preferred link targets, etc
179# To ensure such changes are picked up, we build the published docs with
180# `-E` (to ignore the cached environment) and `-a` (to ignore already existing
181# output files)
Georg Brandlfe427fe2010-03-13 11:02:07 +0000182
183# for development releases: always build
184autobuild-dev:
Juliendff9b5f2017-08-07 10:27:21 +0200185 make dist SPHINXOPTS='$(SPHINXOPTS) -Ea -A daily=1 -A switchers=1'
Georg Brandl44d24292013-11-24 16:17:54 +0100186 -make suspicious
Georg Brandlfe427fe2010-03-13 11:02:07 +0000187
Georg Brandl01f47e82012-10-28 08:09:02 +0100188# for quick rebuilds (HTML only)
Georg Brandl4b9e75b2016-06-15 08:57:32 +0200189autobuild-dev-html:
Juliendff9b5f2017-08-07 10:27:21 +0200190 make html SPHINXOPTS='$(SPHINXOPTS) -Ea -A daily=1 -A switchers=1'
Georg Brandl01f47e82012-10-28 08:09:02 +0100191
Benjamin Petersonefd713b2014-09-24 20:22:24 -0400192# for stable releases: only build if not in pre-release stage (alpha, beta)
193# release candidate downloads are okay, since the stable tree can be in that stage
Georg Brandlfe427fe2010-03-13 11:02:07 +0000194autobuild-stable:
Benjamin Petersonefd713b2014-09-24 20:22:24 -0400195 @case $(DISTVERSION) in *[ab]*) \
Georg Brandl49f47182010-03-13 13:42:16 +0000196 echo "Not building; $(DISTVERSION) is not a release version."; \
197 exit 1;; \
Georg Brandlfe427fe2010-03-13 11:02:07 +0000198 esac
199 @make autobuild-dev
Georg Brandl01f47e82012-10-28 08:09:02 +0100200
Georg Brandl4b9e75b2016-06-15 08:57:32 +0200201autobuild-stable-html:
202 @case $(DISTVERSION) in *[ab]*) \
203 echo "Not building; $(DISTVERSION) is not a release version."; \
204 exit 1;; \
205 esac
206 @make autobuild-dev-html