blob: 8fcf5385730eaad8f11f16271d8ef6451f8fba44 [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 Brandle8693132010-03-13 11:03:05 +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 Brandle8693132010-03-13 11:03:05 +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 Brandle8693132010-03-13 11:03:05 +000036 @echo " check to run a check for frequent markup errors"
Georg Brandl116aa622007-08-15 14:28:22 +000037
Georg Brandl5617db82009-04-27 16:28:57 +000038# Note: if you update versions here, do the same in make.bat and README.txt
Georg Brandl116aa622007-08-15 14:28:22 +000039checkout:
40 @if [ ! -d tools/sphinx ]; then \
41 echo "Checking out Sphinx..."; \
Georg Brandl0c812842010-03-13 10:57:09 +000042 svn checkout $(SVNROOT)/external/Sphinx-0.6.5/sphinx tools/sphinx; \
Georg Brandl116aa622007-08-15 14:28:22 +000043 fi
44 @if [ ! -d tools/docutils ]; then \
45 echo "Checking out Docutils..."; \
Georg Brandl0c812842010-03-13 10:57:09 +000046 svn checkout $(SVNROOT)/external/docutils-0.6/docutils tools/docutils; \
Georg Brandl116aa622007-08-15 14:28:22 +000047 fi
Benjamin Peterson28d88b42009-01-09 03:03:23 +000048 @if [ ! -d tools/jinja2 ]; then \
Benjamin Petersond8607622008-04-13 23:11:15 +000049 echo "Checking out Jinja..."; \
Georg Brandl0c812842010-03-13 10:57:09 +000050 svn checkout $(SVNROOT)/external/Jinja-2.3.1/jinja2 tools/jinja2; \
Benjamin Petersond8607622008-04-13 23:11:15 +000051 fi
Georg Brandl116aa622007-08-15 14:28:22 +000052 @if [ ! -d tools/pygments ]; then \
53 echo "Checking out Pygments..."; \
Georg Brandl0c812842010-03-13 10:57:09 +000054 svn checkout $(SVNROOT)/external/Pygments-1.3.1/pygments tools/pygments; \
Georg Brandl116aa622007-08-15 14:28:22 +000055 fi
56
Georg Brandlda746d72010-03-13 10:02:01 +000057update: clean checkout
Georg Brandl116aa622007-08-15 14:28:22 +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 Brandl116aa622007-08-15 14:28:22 +000068htmlhelp: BUILDER = htmlhelp
69htmlhelp: build
70 @echo "Build finished; now you can run HTML Help Workshop with the" \
Guido van Rossumda27fd22007-08-17 00:24:54 +000071 "build/htmlhelp/pydoc.hhp project file."
Georg Brandl116aa622007-08-15 14:28:22 +000072
Christian Heimesd8654cf2007-12-02 15:22:16 +000073latex: BUILDER = latex
74latex: build
75 @echo "Build finished; the LaTeX files are in build/latex."
Christian Heimes2c181612007-12-17 20:04:13 +000076 @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
77 "run these through (pdf)latex."
Christian Heimesd8654cf2007-12-02 15:22:16 +000078
Georg Brandl0c77a822008-06-10 16:37:50 +000079text: BUILDER = text
80text: build
81 @echo "Build finished; the text files are in build/text."
82
Christian Heimes5b5e81c2007-12-31 16:14:33 +000083changes: BUILDER = changes
84changes: build
85 @echo "The overview file is in build/changes."
86
Christian Heimes292d3512008-02-03 16:51:08 +000087linkcheck: BUILDER = linkcheck
88linkcheck: build
Georg Brandle5e6bc62010-10-06 10:43:34 +000089 @echo "Link check complete; look for any errors in the above output" \
Christian Heimes292d3512008-02-03 16:51:08 +000090 "or in build/$(BUILDER)/output.txt"
91
Benjamin Peterson28d88b42009-01-09 03:03:23 +000092suspicious: BUILDER = suspicious
93suspicious: build
Georg Brandle5e6bc62010-10-06 10:43:34 +000094 @echo "Suspicious check complete; look for any errors in the above output" \
95 "or in build/$(BUILDER)/suspicious.csv. If all issues are false" \
96 "positives, append that file to tools/sphinxext/susp-ignored.csv."
Benjamin Peterson28d88b42009-01-09 03:03:23 +000097
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
Georg Brandle5e6bc62010-10-06 10:43:34 +0000104 @echo "Testing of doctests in the sources finished, look at the" \
Christian Heimesfe337bf2008-03-23 21:54:12 +0000105 "results in build/doctest/output.txt"
106
Georg Brandl6b38daa2008-06-01 21:05:17 +0000107pydoc-topics: BUILDER = pydoc-topics
108pydoc-topics: build
Georg Brandle5e6bc62010-10-06 10:43:34 +0000109 @echo "Building finished; now copy build/pydoc-topics/topics.py" \
Georg Brandl5617db82009-04-27 16:28:57 +0000110 "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
Georg Brandlda746d72010-03-13 10:02:01 +0000118 -rm -rf tools/pygments
119 -rm -rf tools/jinja2
120 -rm -rf tools/docutils
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000121
122dist:
Georg Brandl203947f2010-08-03 12:37:34 +0000123 rm -rf dist
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000124 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
Georg Brandl203947f2010-08-03 12:37:34 +0000145 rm -rf build/latex
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000146 make latex PAPER=a4
Georg Brandl5fd87852010-07-11 08:57:06 +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
Georg Brandl203947f2010-08-03 12:37:34 +0000153 rm -rf build/latex
Benjamin Peterson9bc93512008-09-22 22:10:59 +0000154 make latex PAPER=letter
Georg Brandl5fd87852010-07-11 08:57:06 +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
Georg Brandle8693132010-03-13 11:03:05 +0000162
Georg Brandl8c8430e2010-03-13 13:43:01 +0000163# Targets for daily automated doc build
Georg Brandle8693132010-03-13 11:03:05 +0000164
165# for development releases: always build
166autobuild-dev:
167 make update
Georg Brandl8c8430e2010-03-13 13:43:01 +0000168 make dist SPHINXOPTS='-A daily=1'
Georg Brandle8693132010-03-13 11:03:05 +0000169
Georg Brandl8c8430e2010-03-13 13:43:01 +0000170# for stable releases: only build if not in pre-release stage (alpha, beta, rc)
Georg Brandle8693132010-03-13 11:03:05 +0000171autobuild-stable:
172 @case $(DISTVERSION) in *[abc]*) \
Georg Brandl8c8430e2010-03-13 13:43:01 +0000173 echo "Not building; $(DISTVERSION) is not a release version."; \
174 exit 1;; \
Georg Brandle8693132010-03-13 11:03:05 +0000175 esac
176 @make autobuild-dev