blob: 43dd80478a1e6b1fa0dfbd6c1e50baa7c40d3661 [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 Brandl7094a0c2007-08-15 18:02:37 +00009SPHINXOPTS =
Georg Brandleee1fc52007-12-16 19:36:51 +000010PAPER =
Georg Brandlb98fe5a2008-03-22 10:58:38 +000011SOURCES =
Benjamin Petersonf281ff82008-12-21 21:00:53 +000012DISTVERSION = $(shell $(PYTHON) tools/sphinxext/patchlevel.py)
Georg Brandl8ec7f652007-08-15 14:28:01 +000013
Georg Brandleee1fc52007-12-16 19:36:51 +000014ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees -D latex_paper_size=$(PAPER) \
Georg Brandlb98fe5a2008-03-22 10:58:38 +000015 $(SPHINXOPTS) . build/$(BUILDER) $(SOURCES)
Georg Brandl8ec7f652007-08-15 14:28:01 +000016
Benjamin Peterson423f1282014-09-04 23:07:03 -040017.PHONY: help build html htmlhelp latex text changes linkcheck \
Georg Brandl34465832010-03-13 10:12:39 +000018 suspicious coverage doctest pydoc-topics htmlview clean dist check serve \
19 autobuild-dev autobuild-stable
Georg Brandl8ec7f652007-08-15 14:28:01 +000020
21help:
22 @echo "Please use \`make <target>' where <target> is one of"
Georg Brandl34465832010-03-13 10:12:39 +000023 @echo " clean to remove build files"
Georg Brandl34465832010-03-13 10:12:39 +000024 @echo " html to make standalone HTML files"
Benjamin Peterson423f1282014-09-04 23:07:03 -040025 @echo " htmlview to open the index page built by the html target in your browser"
Georg Brandl34465832010-03-13 10:12:39 +000026 @echo " htmlhelp to make HTML files and a HTML help project"
27 @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
28 @echo " text to make plain text files"
Benjamin Peterson423f1282014-09-04 23:07:03 -040029 @echo " epub to make EPUB files"
Georg Brandl34465832010-03-13 10:12:39 +000030 @echo " changes to make an overview over all changed/added/deprecated items"
31 @echo " linkcheck to check all external links for integrity"
32 @echo " coverage to check documentation coverage for library and C API"
33 @echo " doctest to run doctests in the documentation"
34 @echo " pydoc-topics to regenerate the pydoc topics file"
35 @echo " dist to create a \"dist\" directory with archived docs for download"
Georg Brandl700cf282009-01-04 10:23:49 +000036 @echo " suspicious to check for suspicious markup in output text"
Georg Brandl34465832010-03-13 10:12:39 +000037 @echo " check to run a check for frequent markup errors"
38 @echo " serve to serve the documentation on the localhost (8000)"
Georg Brandl8ec7f652007-08-15 14:28:01 +000039
Benjamin Peterson423f1282014-09-04 23:07:03 -040040build:
41 $(SPHINXBUILD) $(ALLSPHINXOPTS)
Georg Brandl8ec7f652007-08-15 14:28:01 +000042 @echo
43
44html: BUILDER = html
45html: build
46 @echo "Build finished. The HTML pages are in build/html."
47
Georg Brandl8ec7f652007-08-15 14:28:01 +000048htmlhelp: BUILDER = htmlhelp
49htmlhelp: build
50 @echo "Build finished; now you can run HTML Help Workshop with the" \
Georg Brandl09a5c3e2007-08-15 18:30:42 +000051 "build/htmlhelp/pydoc.hhp project file."
Georg Brandl8ec7f652007-08-15 14:28:01 +000052
Georg Brandl584265b2007-12-02 14:58:50 +000053latex: BUILDER = latex
54latex: build
55 @echo "Build finished; the LaTeX files are in build/latex."
Georg Brandleee1fc52007-12-16 19:36:51 +000056 @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
57 "run these through (pdf)latex."
Georg Brandl584265b2007-12-02 14:58:50 +000058
Georg Brandl4f2c9982008-06-01 16:41:31 +000059text: BUILDER = text
60text: build
61 @echo "Build finished; the text files are in build/text."
62
Benjamin Peterson423f1282014-09-04 23:07:03 -040063epub: BUILDER = epub
64epub: build
65 @echo "Build finished; the epub files are in build/epub."
66
Georg Brandlb19be572007-12-29 10:57:00 +000067changes: BUILDER = changes
68changes: build
69 @echo "The overview file is in build/changes."
70
Georg Brandlcd235272008-02-01 15:50:15 +000071linkcheck: BUILDER = linkcheck
Serhiy Storchaka7f7d99c2014-07-22 10:28:36 +030072linkcheck:
73 @$(MAKE) build BUILDER=$(BUILDER) || { \
74 echo "Link check complete; look for any errors in the above output" \
75 "or in build/$(BUILDER)/output.txt"; \
76 false; }
Georg Brandlcd235272008-02-01 15:50:15 +000077
Georg Brandl700cf282009-01-04 10:23:49 +000078suspicious: BUILDER = suspicious
Serhiy Storchaka7f7d99c2014-07-22 10:28:36 +030079suspicious:
80 @$(MAKE) build BUILDER=$(BUILDER) || { \
81 echo "Suspicious check complete; look for any errors in the above output" \
82 "or in build/$(BUILDER)/suspicious.csv. If all issues are false" \
83 "positives, append that file to tools/sphinxext/susp-ignored.csv."; \
84 false; }
Georg Brandl700cf282009-01-04 10:23:49 +000085
Georg Brandl17048282008-02-23 18:47:04 +000086coverage: BUILDER = coverage
87coverage: build
88 @echo "Coverage finished; see c.txt and python.txt in build/coverage"
89
Georg Brandl17baef02008-03-22 10:56:23 +000090doctest: BUILDER = doctest
Serhiy Storchaka7f7d99c2014-07-22 10:28:36 +030091doctest:
92 @$(MAKE) build BUILDER=$(BUILDER) || { \
93 echo "Testing of doctests in the sources finished, look at the" \
94 "results in build/doctest/output.txt"; \
95 false; }
Georg Brandl17baef02008-03-22 10:56:23 +000096
Georg Brandl681001e2008-06-01 20:33:55 +000097pydoc-topics: BUILDER = pydoc-topics
98pydoc-topics: build
Georg Brandl24710632010-10-06 10:47:20 +000099 @echo "Building finished; now copy build/pydoc-topics/topics.py" \
Benjamin Peterson423f1282014-09-04 23:07:03 -0400100 "to ../Lib/pydoc_data/topics.py"
Georg Brandl681001e2008-06-01 20:33:55 +0000101
Benjamin Petersonb279b8a2008-06-26 21:23:30 +0000102htmlview: html
103 $(PYTHON) -c "import webbrowser; webbrowser.open('build/html/index.html')"
Georg Brandl267acd22008-09-21 10:03:39 +0000104
Georg Brandl8ec7f652007-08-15 14:28:01 +0000105clean:
106 -rm -rf build/*
Georg Brandl267acd22008-09-21 10:03:39 +0000107
108dist:
Georg Brandl10c78a72010-08-03 12:37:19 +0000109 rm -rf dist
Georg Brandl267acd22008-09-21 10:03:39 +0000110 mkdir -p dist
111
112 # archive the HTML
113 make html
Benjamin Petersonf281ff82008-12-21 21:00:53 +0000114 cp -pPR build/html dist/python-$(DISTVERSION)-docs-html
115 tar -C dist -cf dist/python-$(DISTVERSION)-docs-html.tar python-$(DISTVERSION)-docs-html
116 bzip2 -9 -k dist/python-$(DISTVERSION)-docs-html.tar
117 (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-html.zip python-$(DISTVERSION)-docs-html)
118 rm -r dist/python-$(DISTVERSION)-docs-html
119 rm dist/python-$(DISTVERSION)-docs-html.tar
Georg Brandl267acd22008-09-21 10:03:39 +0000120
121 # archive the text build
122 make text
Benjamin Petersonf281ff82008-12-21 21:00:53 +0000123 cp -pPR build/text dist/python-$(DISTVERSION)-docs-text
124 tar -C dist -cf dist/python-$(DISTVERSION)-docs-text.tar python-$(DISTVERSION)-docs-text
125 bzip2 -9 -k dist/python-$(DISTVERSION)-docs-text.tar
126 (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-text.zip python-$(DISTVERSION)-docs-text)
127 rm -r dist/python-$(DISTVERSION)-docs-text
128 rm dist/python-$(DISTVERSION)-docs-text.tar
Georg Brandl43819252009-04-26 09:56:44 +0000129
Georg Brandl267acd22008-09-21 10:03:39 +0000130 # archive the A4 latex
Georg Brandl10c78a72010-08-03 12:37:19 +0000131 rm -rf build/latex
Georg Brandl267acd22008-09-21 10:03:39 +0000132 make latex PAPER=a4
Georg Brandl2e73a3f2010-07-11 08:57:05 +0000133 -sed -i 's/makeindex/makeindex -q/' build/latex/Makefile
Georg Brandl267acd22008-09-21 10:03:39 +0000134 (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Petersonf281ff82008-12-21 21:00:53 +0000135 cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-a4.zip
136 cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-a4.tar.bz2
Georg Brandl267acd22008-09-21 10:03:39 +0000137
138 # archive the letter latex
Georg Brandl10c78a72010-08-03 12:37:19 +0000139 rm -rf build/latex
Georg Brandl267acd22008-09-21 10:03:39 +0000140 make latex PAPER=letter
Georg Brandl2e73a3f2010-07-11 08:57:05 +0000141 -sed -i 's/makeindex/makeindex -q/' build/latex/Makefile
Georg Brandl267acd22008-09-21 10:03:39 +0000142 (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Petersonf281ff82008-12-21 21:00:53 +0000143 cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-letter.zip
144 cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-letter.tar.bz2
Georg Brandl267acd22008-09-21 10:03:39 +0000145
Benjamin Peterson423f1282014-09-04 23:07:03 -0400146 # copy the epub build
147 rm -rf build/epub
148 make epub
149 cp -pPR build/epub/Python.epub dist/python-$(DISTVERSION)-docs.epub
150
Georg Brandl9f7a3392009-01-03 20:30:15 +0000151check:
Georg Brandl3b62c2f2009-01-03 21:11:58 +0000152 $(PYTHON) tools/rstlint.py -i tools
Dirkjan Ochtmane4c74e12010-02-24 04:12:11 +0000153
154serve:
155 ../Tools/scripts/serve.py build/html
Georg Brandl34465832010-03-13 10:12:39 +0000156
Georg Brandle82110f2010-03-13 13:39:46 +0000157# Targets for daily automated doc build
Georg Brandl34465832010-03-13 10:12:39 +0000158
159# for development releases: always build
160autobuild-dev:
Ezio Melotti86458902012-10-27 22:28:48 +0300161 make dist SPHINXOPTS='-A daily=1 -A versionswitcher=1'
Georg Brandl40dcf7f2013-11-24 16:17:54 +0100162 -make suspicious
Georg Brandl34465832010-03-13 10:12:39 +0000163
Georg Brandl5fb657d2012-10-28 08:09:02 +0100164# for quick rebuilds (HTML only)
165autobuild-html:
166 make html SPHINXOPTS='-A daily=1 -A versionswitcher=1'
167
Benjamin Peterson423f1282014-09-04 23:07:03 -0400168# for stable releases: only build if not in pre-release stage (alpha, beta, rc)
Georg Brandl34465832010-03-13 10:12:39 +0000169autobuild-stable:
Benjamin Peterson423f1282014-09-04 23:07:03 -0400170 @case $(DISTVERSION) in *[abc]*) \
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