blob: d04106b8d6aadeed9f9f31f4c843ef762d0e2b9d [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.
Guido van Rossumba9c9ac2007-08-18 00:03:44 +00007PYTHON = python2.5
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"
Georg Brandl116aa622007-08-15 14:28:22 +000030
31checkout:
32 @if [ ! -d tools/sphinx ]; then \
33 echo "Checking out Sphinx..."; \
34 svn checkout $(SVNROOT)/doctools/trunk/sphinx tools/sphinx; \
35 fi
36 @if [ ! -d tools/docutils ]; then \
37 echo "Checking out Docutils..."; \
Benjamin Peterson41181742008-07-02 20:22:54 +000038 svn checkout $(SVNROOT)/external/docutils-0.5/docutils tools/docutils; \
Georg Brandl116aa622007-08-15 14:28:22 +000039 fi
Benjamin Peterson28d88b42009-01-09 03:03:23 +000040 @if [ ! -d tools/jinja2 ]; then \
Benjamin Petersond8607622008-04-13 23:11:15 +000041 echo "Checking out Jinja..."; \
Benjamin Peterson28d88b42009-01-09 03:03:23 +000042 svn checkout $(SVNROOT)/external/Jinja-2.1.1/jinja2 tools/jinja2; \
Benjamin Petersond8607622008-04-13 23:11:15 +000043 fi
Georg Brandl116aa622007-08-15 14:28:22 +000044 @if [ ! -d tools/pygments ]; then \
45 echo "Checking out Pygments..."; \
Georg Brandl617027f2008-09-09 19:14:12 +000046 svn checkout $(SVNROOT)/external/Pygments-0.11.1/pygments tools/pygments; \
Georg Brandl116aa622007-08-15 14:28:22 +000047 fi
48
Thomas Woutersbca54802007-09-10 19:32:14 +000049update: checkout
Georg Brandl116aa622007-08-15 14:28:22 +000050 svn update tools/sphinx
51 svn update tools/docutils
Benjamin Peterson28d88b42009-01-09 03:03:23 +000052 svn update tools/jinja2
Georg Brandl116aa622007-08-15 14:28:22 +000053 svn update tools/pygments
54
55build: checkout
56 mkdir -p build/$(BUILDER) build/doctrees
57 $(PYTHON) tools/sphinx-build.py $(ALLSPHINXOPTS)
58 @echo
59
60html: BUILDER = html
61html: build
62 @echo "Build finished. The HTML pages are in build/html."
63
Georg Brandl116aa622007-08-15 14:28:22 +000064htmlhelp: BUILDER = htmlhelp
65htmlhelp: build
66 @echo "Build finished; now you can run HTML Help Workshop with the" \
Guido van Rossumda27fd22007-08-17 00:24:54 +000067 "build/htmlhelp/pydoc.hhp project file."
Georg Brandl116aa622007-08-15 14:28:22 +000068
Christian Heimesd8654cf2007-12-02 15:22:16 +000069latex: BUILDER = latex
70latex: build
71 @echo "Build finished; the LaTeX files are in build/latex."
Christian Heimes2c181612007-12-17 20:04:13 +000072 @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
73 "run these through (pdf)latex."
Christian Heimesd8654cf2007-12-02 15:22:16 +000074
Georg Brandl0c77a822008-06-10 16:37:50 +000075text: BUILDER = text
76text: build
77 @echo "Build finished; the text files are in build/text."
78
Christian Heimes5b5e81c2007-12-31 16:14:33 +000079changes: BUILDER = changes
80changes: build
81 @echo "The overview file is in build/changes."
82
Christian Heimes292d3512008-02-03 16:51:08 +000083linkcheck: BUILDER = linkcheck
84linkcheck: build
Christian Heimesd3eb5a152008-02-24 00:38:49 +000085 @echo "Link check complete; look for any errors in the above output " \
Christian Heimes292d3512008-02-03 16:51:08 +000086 "or in build/$(BUILDER)/output.txt"
87
Benjamin Peterson28d88b42009-01-09 03:03:23 +000088suspicious: BUILDER = suspicious
89suspicious: build
90 @echo "Suspicious check complete; look for any errors in the above output " \
91 "or in build/$(BUILDER)/suspicious.txt"
92
Christian Heimesd3eb5a152008-02-24 00:38:49 +000093coverage: BUILDER = coverage
94coverage: build
95 @echo "Coverage finished; see c.txt and python.txt in build/coverage"
96
Christian Heimesfe337bf2008-03-23 21:54:12 +000097doctest: BUILDER = doctest
98doctest: build
99 @echo "Testing of doctests in the sources finished, look at the " \
100 "results in build/doctest/output.txt"
101
Georg Brandl6b38daa2008-06-01 21:05:17 +0000102pydoc-topics: BUILDER = pydoc-topics
103pydoc-topics: build
104 @echo "Building finished; now copy build/pydoc-topics/pydoc_topics.py " \
105 "into the Lib/ directory"
106
Benjamin Peterson41181742008-07-02 20:22:54 +0000107htmlview: html
108 $(PYTHON) -c "import webbrowser; webbrowser.open('build/html/index.html')"
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000109
Georg Brandl116aa622007-08-15 14:28:22 +0000110clean:
111 -rm -rf build/*
112 -rm -rf tools/sphinx
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000113
114dist:
115 -rm -rf dist
116 mkdir -p dist
117
118 # archive the HTML
119 make html
Benjamin Peterson92035012008-12-27 16:00:54 +0000120 cp -pPR build/html dist/python-$(DISTVERSION)-docs-html
121 tar -C dist -cf dist/python-$(DISTVERSION)-docs-html.tar python-$(DISTVERSION)-docs-html
122 bzip2 -9 -k dist/python-$(DISTVERSION)-docs-html.tar
123 (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-html.zip python-$(DISTVERSION)-docs-html)
124 rm -r dist/python-$(DISTVERSION)-docs-html
125 rm dist/python-$(DISTVERSION)-docs-html.tar
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000126
127 # archive the text build
128 make text
Benjamin Peterson92035012008-12-27 16:00:54 +0000129 cp -pPR build/text dist/python-$(DISTVERSION)-docs-text
130 tar -C dist -cf dist/python-$(DISTVERSION)-docs-text.tar python-$(DISTVERSION)-docs-text
131 bzip2 -9 -k dist/python-$(DISTVERSION)-docs-text.tar
132 (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-text.zip python-$(DISTVERSION)-docs-text)
133 rm -r dist/python-$(DISTVERSION)-docs-text
134 rm dist/python-$(DISTVERSION)-docs-text.tar
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000135
136 # archive the A4 latex
137 -rm -r build/latex
138 make latex PAPER=a4
139 (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Peterson92035012008-12-27 16:00:54 +0000140 cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-a4.zip
141 cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-a4.tar.bz2
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000142
143 # archive the letter latex
144 rm -r build/latex
145 make latex PAPER=letter
146 (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Peterson92035012008-12-27 16:00:54 +0000147 cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-letter.zip
148 cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-letter.tar.bz2
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000149
Georg Brandl45f53372009-01-03 21:15:20 +0000150check:
Georg Brandld5097882009-01-03 21:30:40 +0000151 $(PYTHON) tools/rstlint.py -i tools