blob: f62b25ba65c2ac07db1a2905cfe19797411afb47 [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.
Benjamin Peterson62f71b02009-03-03 22:55:55 +00007PYTHON = python
Guido van Rossumda27fd22007-08-17 00:24:54 +00008SVNROOT = http://svn.python.org/projects
9SPHINXOPTS =
Christian Heimes2c181612007-12-17 20:04:13 +000010PAPER =
Christian Heimesfe337bf2008-03-23 21:54:12 +000011SOURCES =
Benjamin Peterson92035012008-12-27 16:00:54 +000012DISTVERSION = $(shell $(PYTHON) tools/sphinxext/patchlevel.py)
Georg Brandl116aa622007-08-15 14:28:22 +000013
Christian Heimes2c181612007-12-17 20:04:13 +000014ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees -D latex_paper_size=$(PAPER) \
Christian Heimesfe337bf2008-03-23 21:54:12 +000015 $(SPHINXOPTS) . build/$(BUILDER) $(SOURCES)
Georg Brandl116aa622007-08-15 14:28:22 +000016
Georg Brandlfe427fe2010-03-13 11:02:07 +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 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"
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 Peterson28d88b42009-01-09 03:03:23 +000035 @echo " suspicious to check for suspicious markup in output text"
Georg Brandlfe427fe2010-03-13 11:02:07 +000036 @echo " check to run a check for frequent markup errors"
37 @echo " serve to serve the documentation on the localhost (8000)"
Georg Brandl116aa622007-08-15 14:28:22 +000038
Georg Brandl5617db82009-04-27 16:28:57 +000039# Note: if you update versions here, do the same in make.bat and README.txt
Georg Brandl116aa622007-08-15 14:28:22 +000040checkout:
41 @if [ ! -d tools/sphinx ]; then \
42 echo "Checking out Sphinx..."; \
Georg Brandld94b4a72010-03-13 10:56:09 +000043 svn checkout $(SVNROOT)/external/Sphinx-0.6.5/sphinx tools/sphinx; \
Georg Brandl116aa622007-08-15 14:28:22 +000044 fi
45 @if [ ! -d tools/docutils ]; then \
46 echo "Checking out Docutils..."; \
Georg Brandld94b4a72010-03-13 10:56:09 +000047 svn checkout $(SVNROOT)/external/docutils-0.6/docutils tools/docutils; \
Georg Brandl116aa622007-08-15 14:28:22 +000048 fi
Benjamin Peterson28d88b42009-01-09 03:03:23 +000049 @if [ ! -d tools/jinja2 ]; then \
Benjamin Petersond8607622008-04-13 23:11:15 +000050 echo "Checking out Jinja..."; \
Georg Brandld94b4a72010-03-13 10:56:09 +000051 svn checkout $(SVNROOT)/external/Jinja-2.3.1/jinja2 tools/jinja2; \
Benjamin Petersond8607622008-04-13 23:11:15 +000052 fi
Georg Brandl116aa622007-08-15 14:28:22 +000053 @if [ ! -d tools/pygments ]; then \
54 echo "Checking out Pygments..."; \
Georg Brandld94b4a72010-03-13 10:56:09 +000055 svn checkout $(SVNROOT)/external/Pygments-1.3.1/pygments tools/pygments; \
Georg Brandl116aa622007-08-15 14:28:22 +000056 fi
57
Benjamin Petersonb05e73d2009-12-31 03:35:15 +000058update: clean checkout
Georg Brandl116aa622007-08-15 14:28:22 +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 Brandl116aa622007-08-15 14:28:22 +000069htmlhelp: BUILDER = htmlhelp
70htmlhelp: build
71 @echo "Build finished; now you can run HTML Help Workshop with the" \
Guido van Rossumda27fd22007-08-17 00:24:54 +000072 "build/htmlhelp/pydoc.hhp project file."
Georg Brandl116aa622007-08-15 14:28:22 +000073
Christian Heimesd8654cf2007-12-02 15:22:16 +000074latex: BUILDER = latex
75latex: build
76 @echo "Build finished; the LaTeX files are in build/latex."
Christian Heimes2c181612007-12-17 20:04:13 +000077 @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
78 "run these through (pdf)latex."
Christian Heimesd8654cf2007-12-02 15:22:16 +000079
Georg Brandl0c77a822008-06-10 16:37:50 +000080text: BUILDER = text
81text: build
82 @echo "Build finished; the text files are in build/text."
83
Christian Heimes5b5e81c2007-12-31 16:14:33 +000084changes: BUILDER = changes
85changes: build
86 @echo "The overview file is in build/changes."
87
Christian Heimes292d3512008-02-03 16:51:08 +000088linkcheck: BUILDER = linkcheck
89linkcheck: build
Christian Heimesd3eb5a152008-02-24 00:38:49 +000090 @echo "Link check complete; look for any errors in the above output " \
Christian Heimes292d3512008-02-03 16:51:08 +000091 "or in build/$(BUILDER)/output.txt"
92
Benjamin Peterson28d88b42009-01-09 03:03:23 +000093suspicious: BUILDER = suspicious
94suspicious: build
95 @echo "Suspicious check complete; look for any errors in the above output " \
96 "or in build/$(BUILDER)/suspicious.txt"
97
Christian Heimesd3eb5a152008-02-24 00:38:49 +000098coverage: BUILDER = coverage
99coverage: build
100 @echo "Coverage finished; see c.txt and python.txt in build/coverage"
101
Christian Heimesfe337bf2008-03-23 21:54:12 +0000102doctest: BUILDER = doctest
103doctest: build
104 @echo "Testing of doctests in the sources finished, look at the " \
105 "results in build/doctest/output.txt"
106
Georg Brandl6b38daa2008-06-01 21:05:17 +0000107pydoc-topics: BUILDER = pydoc-topics
108pydoc-topics: build
Georg Brandl5617db82009-04-27 16:28:57 +0000109 @echo "Building finished; now copy build/pydoc-topics/topics.py " \
110 "to Lib/pydoc_data/topics.py"
Georg Brandl6b38daa2008-06-01 21:05:17 +0000111
Benjamin Peterson41181742008-07-02 20:22:54 +0000112htmlview: html
113 $(PYTHON) -c "import webbrowser; webbrowser.open('build/html/index.html')"
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000114
Georg Brandl116aa622007-08-15 14:28:22 +0000115clean:
116 -rm -rf build/*
117 -rm -rf tools/sphinx
Benjamin Petersonb05e73d2009-12-31 03:35:15 +0000118 -rm -rf tools/pygments
119 -rm -rf tools/jinja2
120 -rm -rf tools/docutils
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000121
122dist:
123 -rm -rf dist
124 mkdir -p dist
125
126 # archive the HTML
127 make html
Benjamin Peterson92035012008-12-27 16:00:54 +0000128 cp -pPR build/html dist/python-$(DISTVERSION)-docs-html
129 tar -C dist -cf dist/python-$(DISTVERSION)-docs-html.tar python-$(DISTVERSION)-docs-html
130 bzip2 -9 -k dist/python-$(DISTVERSION)-docs-html.tar
131 (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-html.zip python-$(DISTVERSION)-docs-html)
132 rm -r dist/python-$(DISTVERSION)-docs-html
133 rm dist/python-$(DISTVERSION)-docs-html.tar
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000134
135 # archive the text build
136 make text
Benjamin Peterson92035012008-12-27 16:00:54 +0000137 cp -pPR build/text dist/python-$(DISTVERSION)-docs-text
138 tar -C dist -cf dist/python-$(DISTVERSION)-docs-text.tar python-$(DISTVERSION)-docs-text
139 bzip2 -9 -k dist/python-$(DISTVERSION)-docs-text.tar
140 (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-text.zip python-$(DISTVERSION)-docs-text)
141 rm -r dist/python-$(DISTVERSION)-docs-text
142 rm dist/python-$(DISTVERSION)-docs-text.tar
Georg Brandl5617db82009-04-27 16:28:57 +0000143
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000144 # archive the A4 latex
145 -rm -r build/latex
146 make latex PAPER=a4
Georg Brandl692b3f82010-07-11 08:33:16 +0000147 -sed -i 's/makeindex/makeindex -q/' build/latex/Makefile
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000148 (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Peterson92035012008-12-27 16:00:54 +0000149 cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-a4.zip
150 cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-a4.tar.bz2
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000151
152 # archive the letter latex
153 rm -r build/latex
154 make latex PAPER=letter
Georg Brandl692b3f82010-07-11 08:33:16 +0000155 -sed -i 's/makeindex/makeindex -q/' build/latex/Makefile
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000156 (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Peterson92035012008-12-27 16:00:54 +0000157 cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-letter.zip
158 cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-letter.tar.bz2
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000159
Georg Brandl45f53372009-01-03 21:15:20 +0000160check:
Georg Brandld5097882009-01-03 21:30:40 +0000161 $(PYTHON) tools/rstlint.py -i tools
R. David Murraye821cb62010-03-08 17:48:38 +0000162
163serve:
164 ../Tools/scripts/serve.py build/html
Georg Brandlfe427fe2010-03-13 11:02:07 +0000165
Georg Brandl49f47182010-03-13 13:42:16 +0000166# Targets for daily automated doc build
Georg Brandlfe427fe2010-03-13 11:02:07 +0000167
168# for development releases: always build
169autobuild-dev:
170 make update
Georg Brandl49f47182010-03-13 13:42:16 +0000171 make dist SPHINXOPTS='-A daily=1'
Georg Brandlfe427fe2010-03-13 11:02:07 +0000172
Georg Brandl49f47182010-03-13 13:42:16 +0000173# for stable releases: only build if not in pre-release stage (alpha, beta, rc)
Georg Brandlfe427fe2010-03-13 11:02:07 +0000174autobuild-stable:
175 @case $(DISTVERSION) in *[abc]*) \
Georg Brandl49f47182010-03-13 13:42:16 +0000176 echo "Not building; $(DISTVERSION) is not a release version."; \
177 exit 1;; \
Georg Brandlfe427fe2010-03-13 11:02:07 +0000178 esac
179 @make autobuild-dev