blob: 31670ad296ee14108f96a5f2da9e3ebd6d085018 [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 Brandl45f53372009-01-03 21:15:20 +000017.PHONY: help checkout update build html htmlhelp clean coverage dist check
Georg Brandl116aa622007-08-15 14:28:22 +000018
19help:
20 @echo "Please use \`make <target>' where <target> is one of"
Christian Heimes292d3512008-02-03 16:51:08 +000021 @echo " html to make standalone HTML files"
Christian Heimes292d3512008-02-03 16:51:08 +000022 @echo " htmlhelp to make HTML files and a HTML help project"
23 @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
Georg Brandl0c77a822008-06-10 16:37:50 +000024 @echo " text to make plain text files"
Christian Heimes292d3512008-02-03 16:51:08 +000025 @echo " changes to make an overview over all changed/added/deprecated items"
26 @echo " linkcheck to check all external links for integrity"
Benjamin Peterson28d88b42009-01-09 03:03:23 +000027 @echo " suspicious to check for suspicious markup in output text"
Christian Heimesd3eb5a152008-02-24 00:38:49 +000028 @echo " coverage to check documentation coverage for library and C API"
Benjamin Peterson9bc93512008-09-22 22:10:59 +000029 @echo " dist to create a \"dist\" directory with archived docs for download"
R. David Murraye821cb62010-03-08 17:48:38 +000030 @echo " serve to serve the documentation on the localhost (8000)"
Georg Brandl116aa622007-08-15 14:28:22 +000031
Georg Brandl5617db82009-04-27 16:28:57 +000032# Note: if you update versions here, do the same in make.bat and README.txt
Georg Brandl116aa622007-08-15 14:28:22 +000033checkout:
34 @if [ ! -d tools/sphinx ]; then \
35 echo "Checking out Sphinx..."; \
Benjamin Peterson864b3f02009-11-13 23:14:24 +000036 svn checkout $(SVNROOT)/external/Sphinx-0.6.3/sphinx tools/sphinx; \
Georg Brandl116aa622007-08-15 14:28:22 +000037 fi
38 @if [ ! -d tools/docutils ]; then \
39 echo "Checking out Docutils..."; \
Benjamin Peterson41181742008-07-02 20:22:54 +000040 svn checkout $(SVNROOT)/external/docutils-0.5/docutils tools/docutils; \
Georg Brandl116aa622007-08-15 14:28:22 +000041 fi
Benjamin Peterson28d88b42009-01-09 03:03:23 +000042 @if [ ! -d tools/jinja2 ]; then \
Benjamin Petersond8607622008-04-13 23:11:15 +000043 echo "Checking out Jinja..."; \
Benjamin Peterson28d88b42009-01-09 03:03:23 +000044 svn checkout $(SVNROOT)/external/Jinja-2.1.1/jinja2 tools/jinja2; \
Benjamin Petersond8607622008-04-13 23:11:15 +000045 fi
Georg Brandl116aa622007-08-15 14:28:22 +000046 @if [ ! -d tools/pygments ]; then \
47 echo "Checking out Pygments..."; \
Georg Brandl9abe1f12009-12-30 16:24:25 +000048 svn checkout $(SVNROOT)/external/Pygments-1.1.1/pygments tools/pygments; \
Georg Brandl116aa622007-08-15 14:28:22 +000049 fi
50
Benjamin Petersonb05e73d2009-12-31 03:35:15 +000051update: clean checkout
Georg Brandl116aa622007-08-15 14:28:22 +000052
53build: checkout
54 mkdir -p build/$(BUILDER) build/doctrees
55 $(PYTHON) tools/sphinx-build.py $(ALLSPHINXOPTS)
56 @echo
57
58html: BUILDER = html
59html: build
60 @echo "Build finished. The HTML pages are in build/html."
61
Georg Brandl116aa622007-08-15 14:28:22 +000062htmlhelp: BUILDER = htmlhelp
63htmlhelp: build
64 @echo "Build finished; now you can run HTML Help Workshop with the" \
Guido van Rossumda27fd22007-08-17 00:24:54 +000065 "build/htmlhelp/pydoc.hhp project file."
Georg Brandl116aa622007-08-15 14:28:22 +000066
Christian Heimesd8654cf2007-12-02 15:22:16 +000067latex: BUILDER = latex
68latex: build
69 @echo "Build finished; the LaTeX files are in build/latex."
Christian Heimes2c181612007-12-17 20:04:13 +000070 @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
71 "run these through (pdf)latex."
Christian Heimesd8654cf2007-12-02 15:22:16 +000072
Georg Brandl0c77a822008-06-10 16:37:50 +000073text: BUILDER = text
74text: build
75 @echo "Build finished; the text files are in build/text."
76
Christian Heimes5b5e81c2007-12-31 16:14:33 +000077changes: BUILDER = changes
78changes: build
79 @echo "The overview file is in build/changes."
80
Christian Heimes292d3512008-02-03 16:51:08 +000081linkcheck: BUILDER = linkcheck
82linkcheck: build
Christian Heimesd3eb5a152008-02-24 00:38:49 +000083 @echo "Link check complete; look for any errors in the above output " \
Christian Heimes292d3512008-02-03 16:51:08 +000084 "or in build/$(BUILDER)/output.txt"
85
Benjamin Peterson28d88b42009-01-09 03:03:23 +000086suspicious: BUILDER = suspicious
87suspicious: build
88 @echo "Suspicious check complete; look for any errors in the above output " \
89 "or in build/$(BUILDER)/suspicious.txt"
90
Christian Heimesd3eb5a152008-02-24 00:38:49 +000091coverage: BUILDER = coverage
92coverage: build
93 @echo "Coverage finished; see c.txt and python.txt in build/coverage"
94
Christian Heimesfe337bf2008-03-23 21:54:12 +000095doctest: BUILDER = doctest
96doctest: build
97 @echo "Testing of doctests in the sources finished, look at the " \
98 "results in build/doctest/output.txt"
99
Georg Brandl6b38daa2008-06-01 21:05:17 +0000100pydoc-topics: BUILDER = pydoc-topics
101pydoc-topics: build
Georg Brandl5617db82009-04-27 16:28:57 +0000102 @echo "Building finished; now copy build/pydoc-topics/topics.py " \
103 "to Lib/pydoc_data/topics.py"
Georg Brandl6b38daa2008-06-01 21:05:17 +0000104
Benjamin Peterson41181742008-07-02 20:22:54 +0000105htmlview: html
106 $(PYTHON) -c "import webbrowser; webbrowser.open('build/html/index.html')"
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000107
Georg Brandl116aa622007-08-15 14:28:22 +0000108clean:
109 -rm -rf build/*
110 -rm -rf tools/sphinx
Benjamin Petersonb05e73d2009-12-31 03:35:15 +0000111 -rm -rf tools/pygments
112 -rm -rf tools/jinja2
113 -rm -rf tools/docutils
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000114
115dist:
116 -rm -rf dist
117 mkdir -p dist
118
119 # archive the HTML
120 make html
Benjamin Peterson92035012008-12-27 16:00:54 +0000121 cp -pPR build/html dist/python-$(DISTVERSION)-docs-html
122 tar -C dist -cf dist/python-$(DISTVERSION)-docs-html.tar python-$(DISTVERSION)-docs-html
123 bzip2 -9 -k dist/python-$(DISTVERSION)-docs-html.tar
124 (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-html.zip python-$(DISTVERSION)-docs-html)
125 rm -r dist/python-$(DISTVERSION)-docs-html
126 rm dist/python-$(DISTVERSION)-docs-html.tar
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000127
128 # archive the text build
129 make text
Benjamin Peterson92035012008-12-27 16:00:54 +0000130 cp -pPR build/text dist/python-$(DISTVERSION)-docs-text
131 tar -C dist -cf dist/python-$(DISTVERSION)-docs-text.tar python-$(DISTVERSION)-docs-text
132 bzip2 -9 -k dist/python-$(DISTVERSION)-docs-text.tar
133 (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-text.zip python-$(DISTVERSION)-docs-text)
134 rm -r dist/python-$(DISTVERSION)-docs-text
135 rm dist/python-$(DISTVERSION)-docs-text.tar
Georg Brandl5617db82009-04-27 16:28:57 +0000136
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000137 # archive the A4 latex
138 -rm -r build/latex
139 make latex PAPER=a4
140 (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Peterson92035012008-12-27 16:00:54 +0000141 cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-a4.zip
142 cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-a4.tar.bz2
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000143
144 # archive the letter latex
145 rm -r build/latex
146 make latex PAPER=letter
147 (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Peterson92035012008-12-27 16:00:54 +0000148 cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-letter.zip
149 cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-letter.tar.bz2
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000150
Georg Brandl45f53372009-01-03 21:15:20 +0000151check:
Georg Brandld5097882009-01-03 21:30:40 +0000152 $(PYTHON) tools/rstlint.py -i tools
R. David Murraye821cb62010-03-08 17:48:38 +0000153
154serve:
155 ../Tools/scripts/serve.py build/html