blob: 07bf9b280001df6d4ab3400a4f7bdcfe6a19ac3c [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
8SVNROOT = http://svn.python.org/projects
9SPHINXOPTS =
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
Georg Brandl34465832010-03-13 10:12:39 +000017.PHONY: help checkout update build html htmlhelp latex text changes linkcheck \
18 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"
24 @echo " update to update build tools"
25 @echo " html to make standalone HTML files"
26 @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"
29 @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
Georg Brandl43819252009-04-26 09:56:44 +000039# Note: if you update versions here, do the same in make.bat and README.txt
Georg Brandl8ec7f652007-08-15 14:28:01 +000040checkout:
41 @if [ ! -d tools/sphinx ]; then \
42 echo "Checking out Sphinx..."; \
Sandro Tosibbd41d02012-01-14 16:41:26 +010043 svn checkout $(SVNROOT)/external/Sphinx-1.0.7/sphinx tools/sphinx; \
Georg Brandl8ec7f652007-08-15 14:28:01 +000044 fi
45 @if [ ! -d tools/docutils ]; then \
46 echo "Checking out Docutils..."; \
Georg Brandlfce7b862010-03-13 10:54:12 +000047 svn checkout $(SVNROOT)/external/docutils-0.6/docutils tools/docutils; \
Georg Brandl8ec7f652007-08-15 14:28:01 +000048 fi
Benjamin Petersond680d962009-01-04 22:00:18 +000049 @if [ ! -d tools/jinja2 ]; then \
Georg Brandl8ffb5732008-04-13 20:51:27 +000050 echo "Checking out Jinja..."; \
Georg Brandlfce7b862010-03-13 10:54:12 +000051 svn checkout $(SVNROOT)/external/Jinja-2.3.1/jinja2 tools/jinja2; \
Georg Brandl8ffb5732008-04-13 20:51:27 +000052 fi
Georg Brandl8ec7f652007-08-15 14:28:01 +000053 @if [ ! -d tools/pygments ]; then \
54 echo "Checking out Pygments..."; \
Georg Brandlfce7b862010-03-13 10:54:12 +000055 svn checkout $(SVNROOT)/external/Pygments-1.3.1/pygments tools/pygments; \
Georg Brandl8ec7f652007-08-15 14:28:01 +000056 fi
57
Georg Brandle5ee7e32009-12-30 18:36:09 +000058update: clean checkout
Georg Brandl8ec7f652007-08-15 14:28:01 +000059
60build: checkout
61 mkdir -p build/$(BUILDER) build/doctrees
62 $(PYTHON) tools/sphinx-build.py $(ALLSPHINXOPTS)
63 @echo
64
65html: BUILDER = html
66html: build
67 @echo "Build finished. The HTML pages are in build/html."
68
Georg Brandl8ec7f652007-08-15 14:28:01 +000069htmlhelp: BUILDER = htmlhelp
70htmlhelp: build
71 @echo "Build finished; now you can run HTML Help Workshop with the" \
Georg Brandl09a5c3e2007-08-15 18:30:42 +000072 "build/htmlhelp/pydoc.hhp project file."
Georg Brandl8ec7f652007-08-15 14:28:01 +000073
Georg Brandl584265b2007-12-02 14:58:50 +000074latex: BUILDER = latex
75latex: build
76 @echo "Build finished; the LaTeX files are in build/latex."
Georg Brandleee1fc52007-12-16 19:36:51 +000077 @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
78 "run these through (pdf)latex."
Georg Brandl584265b2007-12-02 14:58:50 +000079
Georg Brandl4f2c9982008-06-01 16:41:31 +000080text: BUILDER = text
81text: build
82 @echo "Build finished; the text files are in build/text."
83
Georg Brandlb19be572007-12-29 10:57:00 +000084changes: BUILDER = changes
85changes: build
86 @echo "The overview file is in build/changes."
87
Georg Brandlcd235272008-02-01 15:50:15 +000088linkcheck: BUILDER = linkcheck
Serhiy Storchaka7f7d99c2014-07-22 10:28:36 +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; }
Georg Brandlcd235272008-02-01 15:50:15 +000094
Georg Brandl700cf282009-01-04 10:23:49 +000095suspicious: BUILDER = suspicious
Serhiy Storchaka7f7d99c2014-07-22 10:28:36 +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" \
100 "positives, append that file to tools/sphinxext/susp-ignored.csv."; \
101 false; }
Georg Brandl700cf282009-01-04 10:23:49 +0000102
Georg Brandl17048282008-02-23 18:47:04 +0000103coverage: BUILDER = coverage
104coverage: build
105 @echo "Coverage finished; see c.txt and python.txt in build/coverage"
106
Georg Brandl17baef02008-03-22 10:56:23 +0000107doctest: BUILDER = doctest
Serhiy Storchaka7f7d99c2014-07-22 10:28:36 +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; }
Georg Brandl17baef02008-03-22 10:56:23 +0000113
Georg Brandl681001e2008-06-01 20:33:55 +0000114pydoc-topics: BUILDER = pydoc-topics
115pydoc-topics: build
Georg Brandl24710632010-10-06 10:47:20 +0000116 @echo "Building finished; now copy build/pydoc-topics/topics.py" \
Georg Brandl43819252009-04-26 09:56:44 +0000117 "to Lib/pydoc_data/topics.py"
Georg Brandl681001e2008-06-01 20:33:55 +0000118
Benjamin Petersonb279b8a2008-06-26 21:23:30 +0000119htmlview: html
120 $(PYTHON) -c "import webbrowser; webbrowser.open('build/html/index.html')"
Georg Brandl267acd22008-09-21 10:03:39 +0000121
Georg Brandl8ec7f652007-08-15 14:28:01 +0000122clean:
123 -rm -rf build/*
124 -rm -rf tools/sphinx
Georg Brandle5ee7e32009-12-30 18:36:09 +0000125 -rm -rf tools/pygments
126 -rm -rf tools/jinja2
127 -rm -rf tools/docutils
Georg Brandl267acd22008-09-21 10:03:39 +0000128
129dist:
Georg Brandl10c78a72010-08-03 12:37:19 +0000130 rm -rf dist
Georg Brandl267acd22008-09-21 10:03:39 +0000131 mkdir -p dist
132
133 # archive the HTML
134 make html
Benjamin Petersonf281ff82008-12-21 21:00:53 +0000135 cp -pPR build/html dist/python-$(DISTVERSION)-docs-html
136 tar -C dist -cf dist/python-$(DISTVERSION)-docs-html.tar python-$(DISTVERSION)-docs-html
137 bzip2 -9 -k dist/python-$(DISTVERSION)-docs-html.tar
138 (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-html.zip python-$(DISTVERSION)-docs-html)
139 rm -r dist/python-$(DISTVERSION)-docs-html
140 rm dist/python-$(DISTVERSION)-docs-html.tar
Georg Brandl267acd22008-09-21 10:03:39 +0000141
142 # archive the text build
143 make text
Benjamin Petersonf281ff82008-12-21 21:00:53 +0000144 cp -pPR build/text dist/python-$(DISTVERSION)-docs-text
145 tar -C dist -cf dist/python-$(DISTVERSION)-docs-text.tar python-$(DISTVERSION)-docs-text
146 bzip2 -9 -k dist/python-$(DISTVERSION)-docs-text.tar
147 (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-text.zip python-$(DISTVERSION)-docs-text)
148 rm -r dist/python-$(DISTVERSION)-docs-text
149 rm dist/python-$(DISTVERSION)-docs-text.tar
Georg Brandl43819252009-04-26 09:56:44 +0000150
Georg Brandl267acd22008-09-21 10:03:39 +0000151 # archive the A4 latex
Georg Brandl10c78a72010-08-03 12:37:19 +0000152 rm -rf build/latex
Georg Brandl267acd22008-09-21 10:03:39 +0000153 make latex PAPER=a4
Georg Brandl2e73a3f2010-07-11 08:57:05 +0000154 -sed -i 's/makeindex/makeindex -q/' build/latex/Makefile
Georg Brandl267acd22008-09-21 10:03:39 +0000155 (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Petersonf281ff82008-12-21 21:00:53 +0000156 cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-a4.zip
157 cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-a4.tar.bz2
Georg Brandl267acd22008-09-21 10:03:39 +0000158
159 # archive the letter latex
Georg Brandl10c78a72010-08-03 12:37:19 +0000160 rm -rf build/latex
Georg Brandl267acd22008-09-21 10:03:39 +0000161 make latex PAPER=letter
Georg Brandl2e73a3f2010-07-11 08:57:05 +0000162 -sed -i 's/makeindex/makeindex -q/' build/latex/Makefile
Georg Brandl267acd22008-09-21 10:03:39 +0000163 (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Petersonf281ff82008-12-21 21:00:53 +0000164 cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-letter.zip
165 cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-letter.tar.bz2
Georg Brandl267acd22008-09-21 10:03:39 +0000166
Georg Brandl9f7a3392009-01-03 20:30:15 +0000167check:
Georg Brandl3b62c2f2009-01-03 21:11:58 +0000168 $(PYTHON) tools/rstlint.py -i tools
Dirkjan Ochtmane4c74e12010-02-24 04:12:11 +0000169
170serve:
171 ../Tools/scripts/serve.py build/html
Georg Brandl34465832010-03-13 10:12:39 +0000172
Georg Brandle82110f2010-03-13 13:39:46 +0000173# Targets for daily automated doc build
Georg Brandl34465832010-03-13 10:12:39 +0000174
175# for development releases: always build
176autobuild-dev:
177 make update
Ezio Melotti86458902012-10-27 22:28:48 +0300178 make dist SPHINXOPTS='-A daily=1 -A versionswitcher=1'
Georg Brandl40dcf7f2013-11-24 16:17:54 +0100179 -make suspicious
Georg Brandl34465832010-03-13 10:12:39 +0000180
Georg Brandl5fb657d2012-10-28 08:09:02 +0100181# for quick rebuilds (HTML only)
182autobuild-html:
183 make html SPHINXOPTS='-A daily=1 -A versionswitcher=1'
184
Benjamin Petersond383baf2014-05-24 15:15:26 -0700185# for stable releases: only build if not in pre-release stage (alpha, beta)
186# release candidate downloads are okay, since the stable tree can be in that stage
Georg Brandl34465832010-03-13 10:12:39 +0000187autobuild-stable:
Benjamin Petersond383baf2014-05-24 15:15:26 -0700188 @case $(DISTVERSION) in *[ab]*) \
Georg Brandle82110f2010-03-13 13:39:46 +0000189 echo "Not building; $(DISTVERSION) is not a release version."; \
190 exit 1;; \
Georg Brandl34465832010-03-13 10:12:39 +0000191 esac
192 @make autobuild-dev
Georg Brandl5fb657d2012-10-28 08:09:02 +0100193