blob: f82acebd9392dbcba1474d4ece3c86cb0ade7327 [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 Peterson828a7062008-12-27 17:05:29 +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 Brandl10b4e8c2010-03-13 11:00:44 +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 Brandl10b4e8c2010-03-13 11:00:44 +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"
Benjamin Peterson9f7ae1b2009-01-09 03:04:01 +000035 @echo " suspicious to check for suspicious markup in output text"
Georg Brandl10b4e8c2010-03-13 11:00:44 +000036 @echo " check to run a check for frequent markup errors"
Georg Brandl8ec7f652007-08-15 14:28:01 +000037
Georg Brandl6d1169b2009-04-28 18:24:36 +000038# Note: if you update versions here, do the same in make.bat and README.txt
Georg Brandl8ec7f652007-08-15 14:28:01 +000039checkout:
40 @if [ ! -d tools/sphinx ]; then \
41 echo "Checking out Sphinx..."; \
Georg Brandlb01f9432010-03-13 10:59:09 +000042 svn checkout $(SVNROOT)/external/Sphinx-0.6.5/sphinx tools/sphinx; \
Georg Brandl8ec7f652007-08-15 14:28:01 +000043 fi
44 @if [ ! -d tools/docutils ]; then \
45 echo "Checking out Docutils..."; \
Georg Brandlb01f9432010-03-13 10:59:09 +000046 svn checkout $(SVNROOT)/external/docutils-0.6/docutils tools/docutils; \
Georg Brandl8ec7f652007-08-15 14:28:01 +000047 fi
Benjamin Peterson9f7ae1b2009-01-09 03:04:01 +000048 @if [ ! -d tools/jinja2 ]; then \
Georg Brandl8ffb5732008-04-13 20:51:27 +000049 echo "Checking out Jinja..."; \
Georg Brandlb01f9432010-03-13 10:59:09 +000050 svn checkout $(SVNROOT)/external/Jinja-2.3.1/jinja2 tools/jinja2; \
Georg Brandl8ffb5732008-04-13 20:51:27 +000051 fi
Georg Brandl8ec7f652007-08-15 14:28:01 +000052 @if [ ! -d tools/pygments ]; then \
53 echo "Checking out Pygments..."; \
Georg Brandlb01f9432010-03-13 10:59:09 +000054 svn checkout $(SVNROOT)/external/Pygments-1.3.1/pygments tools/pygments; \
Georg Brandl8ec7f652007-08-15 14:28:01 +000055 fi
56
Georg Brandlde1838c2010-03-13 10:02:09 +000057update: clean checkout
Georg Brandl8ec7f652007-08-15 14:28:01 +000058
59build: checkout
60 mkdir -p build/$(BUILDER) build/doctrees
61 $(PYTHON) tools/sphinx-build.py $(ALLSPHINXOPTS)
62 @echo
63
64html: BUILDER = html
65html: build
66 @echo "Build finished. The HTML pages are in build/html."
67
Georg Brandl8ec7f652007-08-15 14:28:01 +000068htmlhelp: BUILDER = htmlhelp
69htmlhelp: build
70 @echo "Build finished; now you can run HTML Help Workshop with the" \
Georg Brandl09a5c3e2007-08-15 18:30:42 +000071 "build/htmlhelp/pydoc.hhp project file."
Georg Brandl8ec7f652007-08-15 14:28:01 +000072
Georg Brandl584265b2007-12-02 14:58:50 +000073latex: BUILDER = latex
74latex: build
75 @echo "Build finished; the LaTeX files are in build/latex."
Georg Brandleee1fc52007-12-16 19:36:51 +000076 @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
77 "run these through (pdf)latex."
Georg Brandl584265b2007-12-02 14:58:50 +000078
Georg Brandl4f2c9982008-06-01 16:41:31 +000079text: BUILDER = text
80text: build
81 @echo "Build finished; the text files are in build/text."
82
Georg Brandlb19be572007-12-29 10:57:00 +000083changes: BUILDER = changes
84changes: build
85 @echo "The overview file is in build/changes."
86
Georg Brandlcd235272008-02-01 15:50:15 +000087linkcheck: BUILDER = linkcheck
88linkcheck: build
Georg Brandl17048282008-02-23 18:47:04 +000089 @echo "Link check complete; look for any errors in the above output " \
Georg Brandl7be67ff2008-02-01 19:24:01 +000090 "or in build/$(BUILDER)/output.txt"
Georg Brandlcd235272008-02-01 15:50:15 +000091
Benjamin Peterson9f7ae1b2009-01-09 03:04:01 +000092suspicious: BUILDER = suspicious
93suspicious: build
94 @echo "Suspicious check complete; look for any errors in the above output " \
95 "or in build/$(BUILDER)/suspicious.txt"
96
Georg Brandl17048282008-02-23 18:47:04 +000097coverage: BUILDER = coverage
98coverage: build
99 @echo "Coverage finished; see c.txt and python.txt in build/coverage"
100
Georg Brandl17baef02008-03-22 10:56:23 +0000101doctest: BUILDER = doctest
102doctest: build
103 @echo "Testing of doctests in the sources finished, look at the " \
104 "results in build/doctest/output.txt"
105
Georg Brandl681001e2008-06-01 20:33:55 +0000106pydoc-topics: BUILDER = pydoc-topics
107pydoc-topics: build
108 @echo "Building finished; now copy build/pydoc-topics/pydoc_topics.py " \
109 "into the Lib/ directory"
110
Benjamin Petersonb279b8a2008-06-26 21:23:30 +0000111htmlview: html
112 $(PYTHON) -c "import webbrowser; webbrowser.open('build/html/index.html')"
Georg Brandl267acd22008-09-21 10:03:39 +0000113
Georg Brandl8ec7f652007-08-15 14:28:01 +0000114clean:
115 -rm -rf build/*
116 -rm -rf tools/sphinx
Georg Brandlde1838c2010-03-13 10:02:09 +0000117 -rm -rf tools/pygments
118 -rm -rf tools/jinja2
119 -rm -rf tools/docutils
Georg Brandl267acd22008-09-21 10:03:39 +0000120
121dist:
122 -rm -rf dist
123 mkdir -p dist
124
125 # archive the HTML
126 make html
Benjamin Peterson828a7062008-12-27 17:05:29 +0000127 cp -pPR build/html dist/python-$(DISTVERSION)-docs-html
128 tar -C dist -cf dist/python-$(DISTVERSION)-docs-html.tar python-$(DISTVERSION)-docs-html
129 bzip2 -9 -k dist/python-$(DISTVERSION)-docs-html.tar
130 (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-html.zip python-$(DISTVERSION)-docs-html)
131 rm -r dist/python-$(DISTVERSION)-docs-html
132 rm dist/python-$(DISTVERSION)-docs-html.tar
Georg Brandl267acd22008-09-21 10:03:39 +0000133
134 # archive the text build
135 make text
Benjamin Peterson828a7062008-12-27 17:05:29 +0000136 cp -pPR build/text dist/python-$(DISTVERSION)-docs-text
137 tar -C dist -cf dist/python-$(DISTVERSION)-docs-text.tar python-$(DISTVERSION)-docs-text
138 bzip2 -9 -k dist/python-$(DISTVERSION)-docs-text.tar
139 (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-text.zip python-$(DISTVERSION)-docs-text)
140 rm -r dist/python-$(DISTVERSION)-docs-text
141 rm dist/python-$(DISTVERSION)-docs-text.tar
Georg Brandl267acd22008-09-21 10:03:39 +0000142
143 # archive the A4 latex
144 -rm -r build/latex
145 make latex PAPER=a4
146 (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Peterson828a7062008-12-27 17:05:29 +0000147 cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-a4.zip
148 cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-a4.tar.bz2
Georg Brandl267acd22008-09-21 10:03:39 +0000149
150 # archive the letter latex
151 rm -r build/latex
152 make latex PAPER=letter
153 (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Peterson828a7062008-12-27 17:05:29 +0000154 cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-letter.zip
155 cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-letter.tar.bz2
Georg Brandl267acd22008-09-21 10:03:39 +0000156
Georg Brandl734373c2009-01-03 21:55:17 +0000157check:
158 $(PYTHON) tools/rstlint.py -i tools
Georg Brandl10b4e8c2010-03-13 11:00:44 +0000159
Georg Brandla93c4e32010-03-13 13:42:13 +0000160# Targets for daily automated doc build
Georg Brandl10b4e8c2010-03-13 11:00:44 +0000161
162# for development releases: always build
163autobuild-dev:
164 make update
Georg Brandla93c4e32010-03-13 13:42:13 +0000165 make dist SPHINXOPTS='-A daily=1'
Georg Brandl10b4e8c2010-03-13 11:00:44 +0000166
Georg Brandla93c4e32010-03-13 13:42:13 +0000167# for stable releases: only build if not in pre-release stage (alpha, beta, rc)
Georg Brandl10b4e8c2010-03-13 11:00:44 +0000168autobuild-stable:
169 @case $(DISTVERSION) in *[abc]*) \
Georg Brandla93c4e32010-03-13 13:42:13 +0000170 echo "Not building; $(DISTVERSION) is not a release version."; \
171 exit 1;; \
Georg Brandl10b4e8c2010-03-13 11:00:44 +0000172 esac
173 @make autobuild-dev