blob: ea3023157dd75bb1f92ccc92325afe6220351587 [file] [log] [blame]
Georg Brandl8ec7f652007-08-15 14:28:01 +00001#
2# Makefile for Python documentation
3# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4#
5
6# You can set these variables from the command line.
Georg Brandl7094a0c2007-08-15 18:02:37 +00007PYTHON = python
Benjamin Peterson423f1282014-09-04 23:07:03 -04008SPHINXBUILD = sphinx-build
Georg Brandleee1fc52007-12-16 19:36:51 +00009PAPER =
Georg Brandlb98fe5a2008-03-22 10:58:38 +000010SOURCES =
Benjamin Peterson402bd792014-12-10 11:04:17 -050011DISTVERSION = $(shell $(PYTHON) tools/extensions/patchlevel.py)
Georg Brandl8ec7f652007-08-15 14:28:01 +000012
Georg Brandleee1fc52007-12-16 19:36:51 +000013ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees -D latex_paper_size=$(PAPER) \
Georg Brandlb98fe5a2008-03-22 10:58:38 +000014 $(SPHINXOPTS) . build/$(BUILDER) $(SOURCES)
Georg Brandl8ec7f652007-08-15 14:28:01 +000015
Benjamin Peterson423f1282014-09-04 23:07:03 -040016.PHONY: help build html htmlhelp latex text changes linkcheck \
Georg Brandl34465832010-03-13 10:12:39 +000017 suspicious coverage doctest pydoc-topics htmlview clean dist check serve \
18 autobuild-dev autobuild-stable
Georg Brandl8ec7f652007-08-15 14:28:01 +000019
20help:
21 @echo "Please use \`make <target>' where <target> is one of"
Georg Brandl34465832010-03-13 10:12:39 +000022 @echo " clean to remove build files"
Georg Brandl34465832010-03-13 10:12:39 +000023 @echo " html to make standalone HTML files"
Benjamin Peterson423f1282014-09-04 23:07:03 -040024 @echo " htmlview to open the index page built by the html target in your browser"
Georg Brandl34465832010-03-13 10:12:39 +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"
Benjamin Peterson423f1282014-09-04 23:07:03 -040028 @echo " epub to make EPUB files"
Georg Brandl34465832010-03-13 10:12:39 +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"
Georg Brandl700cf282009-01-04 10:23:49 +000035 @echo " suspicious to check for suspicious markup in output text"
Georg Brandl34465832010-03-13 10:12:39 +000036 @echo " check to run a check for frequent markup errors"
37 @echo " serve to serve the documentation on the localhost (8000)"
Georg Brandl8ec7f652007-08-15 14:28:01 +000038
Benjamin Peterson423f1282014-09-04 23:07:03 -040039build:
40 $(SPHINXBUILD) $(ALLSPHINXOPTS)
Georg Brandl8ec7f652007-08-15 14:28:01 +000041 @echo
42
43html: BUILDER = html
44html: build
45 @echo "Build finished. The HTML pages are in build/html."
46
Georg Brandl8ec7f652007-08-15 14:28:01 +000047htmlhelp: BUILDER = htmlhelp
48htmlhelp: build
49 @echo "Build finished; now you can run HTML Help Workshop with the" \
Georg Brandl09a5c3e2007-08-15 18:30:42 +000050 "build/htmlhelp/pydoc.hhp project file."
Georg Brandl8ec7f652007-08-15 14:28:01 +000051
Georg Brandl584265b2007-12-02 14:58:50 +000052latex: BUILDER = latex
53latex: build
54 @echo "Build finished; the LaTeX files are in build/latex."
Georg Brandleee1fc52007-12-16 19:36:51 +000055 @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
56 "run these through (pdf)latex."
Georg Brandl584265b2007-12-02 14:58:50 +000057
Georg Brandl4f2c9982008-06-01 16:41:31 +000058text: BUILDER = text
59text: build
60 @echo "Build finished; the text files are in build/text."
61
Benjamin Peterson423f1282014-09-04 23:07:03 -040062epub: BUILDER = epub
63epub: build
64 @echo "Build finished; the epub files are in build/epub."
65
Georg Brandlb19be572007-12-29 10:57:00 +000066changes: BUILDER = changes
67changes: build
68 @echo "The overview file is in build/changes."
69
Georg Brandlcd235272008-02-01 15:50:15 +000070linkcheck: BUILDER = linkcheck
Serhiy Storchaka7f7d99c2014-07-22 10:28:36 +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; }
Georg Brandlcd235272008-02-01 15:50:15 +000076
Georg Brandl700cf282009-01-04 10:23:49 +000077suspicious: BUILDER = suspicious
Serhiy Storchaka7f7d99c2014-07-22 10:28:36 +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 Brandlf16fbf92014-09-30 22:51:30 +020082 "positives, append that file to tools/susp-ignored.csv."; \
Serhiy Storchaka7f7d99c2014-07-22 10:28:36 +030083 false; }
Georg Brandl700cf282009-01-04 10:23:49 +000084
Georg Brandl17048282008-02-23 18:47:04 +000085coverage: BUILDER = coverage
86coverage: build
87 @echo "Coverage finished; see c.txt and python.txt in build/coverage"
88
Georg Brandl17baef02008-03-22 10:56:23 +000089doctest: BUILDER = doctest
Serhiy Storchaka7f7d99c2014-07-22 10:28:36 +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; }
Georg Brandl17baef02008-03-22 10:56:23 +000095
Georg Brandl681001e2008-06-01 20:33:55 +000096pydoc-topics: BUILDER = pydoc-topics
97pydoc-topics: build
Georg Brandl24710632010-10-06 10:47:20 +000098 @echo "Building finished; now copy build/pydoc-topics/topics.py" \
Benjamin Peterson423f1282014-09-04 23:07:03 -040099 "to ../Lib/pydoc_data/topics.py"
Georg Brandl681001e2008-06-01 20:33:55 +0000100
Benjamin Petersonb279b8a2008-06-26 21:23:30 +0000101htmlview: html
102 $(PYTHON) -c "import webbrowser; webbrowser.open('build/html/index.html')"
Georg Brandl267acd22008-09-21 10:03:39 +0000103
Georg Brandl8ec7f652007-08-15 14:28:01 +0000104clean:
105 -rm -rf build/*
Georg Brandl267acd22008-09-21 10:03:39 +0000106
107dist:
Georg Brandl10c78a72010-08-03 12:37:19 +0000108 rm -rf dist
Georg Brandl267acd22008-09-21 10:03:39 +0000109 mkdir -p dist
110
111 # archive the HTML
112 make html
Benjamin Petersonf281ff82008-12-21 21:00:53 +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
Georg Brandl267acd22008-09-21 10:03:39 +0000119
120 # archive the text build
121 make text
Benjamin Petersonf281ff82008-12-21 21:00:53 +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 Brandl43819252009-04-26 09:56:44 +0000128
Georg Brandl267acd22008-09-21 10:03:39 +0000129 # archive the A4 latex
Georg Brandl10c78a72010-08-03 12:37:19 +0000130 rm -rf build/latex
Georg Brandl267acd22008-09-21 10:03:39 +0000131 make latex PAPER=a4
Georg Brandl2e73a3f2010-07-11 08:57:05 +0000132 -sed -i 's/makeindex/makeindex -q/' build/latex/Makefile
Georg Brandl267acd22008-09-21 10:03:39 +0000133 (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Petersonf281ff82008-12-21 21:00:53 +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
Georg Brandl267acd22008-09-21 10:03:39 +0000136
137 # archive the letter latex
Georg Brandl10c78a72010-08-03 12:37:19 +0000138 rm -rf build/latex
Georg Brandl267acd22008-09-21 10:03:39 +0000139 make latex PAPER=letter
Georg Brandl2e73a3f2010-07-11 08:57:05 +0000140 -sed -i 's/makeindex/makeindex -q/' build/latex/Makefile
Georg Brandl267acd22008-09-21 10:03:39 +0000141 (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Petersonf281ff82008-12-21 21:00:53 +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
Georg Brandl267acd22008-09-21 10:03:39 +0000144
Benjamin Peterson423f1282014-09-04 23:07:03 -0400145 # copy the epub build
146 rm -rf build/epub
147 make epub
148 cp -pPR build/epub/Python.epub dist/python-$(DISTVERSION)-docs.epub
149
Georg Brandl9f7a3392009-01-03 20:30:15 +0000150check:
Georg Brandl3b62c2f2009-01-03 21:11:58 +0000151 $(PYTHON) tools/rstlint.py -i tools
Dirkjan Ochtmane4c74e12010-02-24 04:12:11 +0000152
153serve:
154 ../Tools/scripts/serve.py build/html
Georg Brandl34465832010-03-13 10:12:39 +0000155
Georg Brandle82110f2010-03-13 13:39:46 +0000156# Targets for daily automated doc build
Georg Brandl34465832010-03-13 10:12:39 +0000157
158# for development releases: always build
159autobuild-dev:
Ezio Melotti86458902012-10-27 22:28:48 +0300160 make dist SPHINXOPTS='-A daily=1 -A versionswitcher=1'
Georg Brandl40dcf7f2013-11-24 16:17:54 +0100161 -make suspicious
Georg Brandl34465832010-03-13 10:12:39 +0000162
Georg Brandl5fb657d2012-10-28 08:09:02 +0100163# for quick rebuilds (HTML only)
164autobuild-html:
165 make html SPHINXOPTS='-A daily=1 -A versionswitcher=1'
166
Benjamin Petersond1a4f992014-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 Brandl34465832010-03-13 10:12:39 +0000169autobuild-stable:
Benjamin Petersond1a4f992014-09-24 20:22:24 -0400170 @case $(DISTVERSION) in *[ab]*) \
Georg Brandle82110f2010-03-13 13:39:46 +0000171 echo "Not building; $(DISTVERSION) is not a release version."; \
172 exit 1;; \
Georg Brandl34465832010-03-13 10:12:39 +0000173 esac
174 @make autobuild-dev
Georg Brandl5fb657d2012-10-28 08:09:02 +0100175