blob: f824eba2c3d36a07a2c4e5333b1861e4dd8c53ef [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 Petersonf281ff82008-12-21 21:00:53 +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 Brandl34465832010-03-13 10:12:39 +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 Brandl34465832010-03-13 10:12:39 +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"
Georg Brandl700cf282009-01-04 10:23:49 +000035 @echo " suspicious to check for suspicious markup in output text"
Georg Brandl34465832010-03-13 10:12:39 +000036 @echo " check to run a check for frequent markup errors"
37 @echo " serve to serve the documentation on the localhost (8000)"
Georg Brandl8ec7f652007-08-15 14:28:01 +000038
Georg Brandl43819252009-04-26 09:56:44 +000039# Note: if you update versions here, do the same in make.bat and README.txt
Georg Brandl8ec7f652007-08-15 14:28:01 +000040checkout:
41 @if [ ! -d tools/sphinx ]; then \
42 echo "Checking out Sphinx..."; \
Georg Brandlfce7b862010-03-13 10:54:12 +000043 svn checkout $(SVNROOT)/external/Sphinx-0.6.5/sphinx tools/sphinx; \
Georg Brandl8ec7f652007-08-15 14:28:01 +000044 fi
45 @if [ ! -d tools/docutils ]; then \
46 echo "Checking out Docutils..."; \
Georg Brandlfce7b862010-03-13 10:54:12 +000047 svn checkout $(SVNROOT)/external/docutils-0.6/docutils tools/docutils; \
Georg Brandl8ec7f652007-08-15 14:28:01 +000048 fi
Benjamin Petersond680d962009-01-04 22:00:18 +000049 @if [ ! -d tools/jinja2 ]; then \
Georg Brandl8ffb5732008-04-13 20:51:27 +000050 echo "Checking out Jinja..."; \
Georg Brandlfce7b862010-03-13 10:54:12 +000051 svn checkout $(SVNROOT)/external/Jinja-2.3.1/jinja2 tools/jinja2; \
Georg Brandl8ffb5732008-04-13 20:51:27 +000052 fi
Georg Brandl8ec7f652007-08-15 14:28:01 +000053 @if [ ! -d tools/pygments ]; then \
54 echo "Checking out Pygments..."; \
Georg Brandlfce7b862010-03-13 10:54:12 +000055 svn checkout $(SVNROOT)/external/Pygments-1.3.1/pygments tools/pygments; \
Georg Brandl8ec7f652007-08-15 14:28:01 +000056 fi
57
Georg Brandle5ee7e32009-12-30 18:36:09 +000058update: clean checkout
Georg Brandl8ec7f652007-08-15 14:28:01 +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 Brandl8ec7f652007-08-15 14:28:01 +000069htmlhelp: BUILDER = htmlhelp
70htmlhelp: build
71 @echo "Build finished; now you can run HTML Help Workshop with the" \
Georg Brandl09a5c3e2007-08-15 18:30:42 +000072 "build/htmlhelp/pydoc.hhp project file."
Georg Brandl8ec7f652007-08-15 14:28:01 +000073
Georg Brandl584265b2007-12-02 14:58:50 +000074latex: BUILDER = latex
75latex: build
76 @echo "Build finished; the LaTeX files are in build/latex."
Georg Brandleee1fc52007-12-16 19:36:51 +000077 @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
78 "run these through (pdf)latex."
Georg Brandl584265b2007-12-02 14:58:50 +000079
Georg Brandl4f2c9982008-06-01 16:41:31 +000080text: BUILDER = text
81text: build
82 @echo "Build finished; the text files are in build/text."
83
Georg Brandlb19be572007-12-29 10:57:00 +000084changes: BUILDER = changes
85changes: build
86 @echo "The overview file is in build/changes."
87
Georg Brandlcd235272008-02-01 15:50:15 +000088linkcheck: BUILDER = linkcheck
89linkcheck: build
Georg Brandl24710632010-10-06 10:47:20 +000090 @echo "Link check complete; look for any errors in the above output" \
Georg Brandl7be67ff2008-02-01 19:24:01 +000091 "or in build/$(BUILDER)/output.txt"
Georg Brandlcd235272008-02-01 15:50:15 +000092
Georg Brandl700cf282009-01-04 10:23:49 +000093suspicious: BUILDER = suspicious
94suspicious: build
Georg Brandl24710632010-10-06 10:47:20 +000095 @echo "Suspicious check complete; look for any errors in the above output" \
96 "or in build/$(BUILDER)/suspicious.csv. If all issues are false" \
97 "positives, append that file to tools/sphinxext/susp-ignored.csv."
Georg Brandl700cf282009-01-04 10:23:49 +000098
Georg Brandl17048282008-02-23 18:47:04 +000099coverage: BUILDER = coverage
100coverage: build
101 @echo "Coverage finished; see c.txt and python.txt in build/coverage"
102
Georg Brandl17baef02008-03-22 10:56:23 +0000103doctest: BUILDER = doctest
104doctest: build
Georg Brandl24710632010-10-06 10:47:20 +0000105 @echo "Testing of doctests in the sources finished, look at the" \
Georg Brandl17baef02008-03-22 10:56:23 +0000106 "results in build/doctest/output.txt"
107
Georg Brandl681001e2008-06-01 20:33:55 +0000108pydoc-topics: BUILDER = pydoc-topics
109pydoc-topics: build
Georg Brandl24710632010-10-06 10:47:20 +0000110 @echo "Building finished; now copy build/pydoc-topics/topics.py" \
Georg Brandl43819252009-04-26 09:56:44 +0000111 "to Lib/pydoc_data/topics.py"
Georg Brandl681001e2008-06-01 20:33:55 +0000112
Benjamin Petersonb279b8a2008-06-26 21:23:30 +0000113htmlview: html
114 $(PYTHON) -c "import webbrowser; webbrowser.open('build/html/index.html')"
Georg Brandl267acd22008-09-21 10:03:39 +0000115
Georg Brandl8ec7f652007-08-15 14:28:01 +0000116clean:
117 -rm -rf build/*
118 -rm -rf tools/sphinx
Georg Brandle5ee7e32009-12-30 18:36:09 +0000119 -rm -rf tools/pygments
120 -rm -rf tools/jinja2
121 -rm -rf tools/docutils
Georg Brandl267acd22008-09-21 10:03:39 +0000122
123dist:
Georg Brandl10c78a72010-08-03 12:37:19 +0000124 rm -rf dist
Georg Brandl267acd22008-09-21 10:03:39 +0000125 mkdir -p dist
126
127 # archive the HTML
128 make html
Benjamin Petersonf281ff82008-12-21 21:00:53 +0000129 cp -pPR build/html dist/python-$(DISTVERSION)-docs-html
130 tar -C dist -cf dist/python-$(DISTVERSION)-docs-html.tar python-$(DISTVERSION)-docs-html
131 bzip2 -9 -k dist/python-$(DISTVERSION)-docs-html.tar
132 (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-html.zip python-$(DISTVERSION)-docs-html)
133 rm -r dist/python-$(DISTVERSION)-docs-html
134 rm dist/python-$(DISTVERSION)-docs-html.tar
Georg Brandl267acd22008-09-21 10:03:39 +0000135
136 # archive the text build
137 make text
Benjamin Petersonf281ff82008-12-21 21:00:53 +0000138 cp -pPR build/text dist/python-$(DISTVERSION)-docs-text
139 tar -C dist -cf dist/python-$(DISTVERSION)-docs-text.tar python-$(DISTVERSION)-docs-text
140 bzip2 -9 -k dist/python-$(DISTVERSION)-docs-text.tar
141 (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-text.zip python-$(DISTVERSION)-docs-text)
142 rm -r dist/python-$(DISTVERSION)-docs-text
143 rm dist/python-$(DISTVERSION)-docs-text.tar
Georg Brandl43819252009-04-26 09:56:44 +0000144
Georg Brandl267acd22008-09-21 10:03:39 +0000145 # archive the A4 latex
Georg Brandl10c78a72010-08-03 12:37:19 +0000146 rm -rf build/latex
Georg Brandl267acd22008-09-21 10:03:39 +0000147 make latex PAPER=a4
Georg Brandl2e73a3f2010-07-11 08:57:05 +0000148 -sed -i 's/makeindex/makeindex -q/' build/latex/Makefile
Georg Brandl267acd22008-09-21 10:03:39 +0000149 (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Petersonf281ff82008-12-21 21:00:53 +0000150 cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-a4.zip
151 cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-a4.tar.bz2
Georg Brandl267acd22008-09-21 10:03:39 +0000152
153 # archive the letter latex
Georg Brandl10c78a72010-08-03 12:37:19 +0000154 rm -rf build/latex
Georg Brandl267acd22008-09-21 10:03:39 +0000155 make latex PAPER=letter
Georg Brandl2e73a3f2010-07-11 08:57:05 +0000156 -sed -i 's/makeindex/makeindex -q/' build/latex/Makefile
Georg Brandl267acd22008-09-21 10:03:39 +0000157 (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Petersonf281ff82008-12-21 21:00:53 +0000158 cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-letter.zip
159 cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-letter.tar.bz2
Georg Brandl267acd22008-09-21 10:03:39 +0000160
Georg Brandl9f7a3392009-01-03 20:30:15 +0000161check:
Georg Brandl3b62c2f2009-01-03 21:11:58 +0000162 $(PYTHON) tools/rstlint.py -i tools
Dirkjan Ochtmane4c74e12010-02-24 04:12:11 +0000163
164serve:
165 ../Tools/scripts/serve.py build/html
Georg Brandl34465832010-03-13 10:12:39 +0000166
Georg Brandle82110f2010-03-13 13:39:46 +0000167# Targets for daily automated doc build
Georg Brandl34465832010-03-13 10:12:39 +0000168
169# for development releases: always build
170autobuild-dev:
171 make update
Georg Brandle82110f2010-03-13 13:39:46 +0000172 make dist SPHINXOPTS='-A daily=1'
Georg Brandl34465832010-03-13 10:12:39 +0000173
Georg Brandle82110f2010-03-13 13:39:46 +0000174# for stable releases: only build if not in pre-release stage (alpha, beta, rc)
Georg Brandl34465832010-03-13 10:12:39 +0000175autobuild-stable:
176 @case $(DISTVERSION) in *[abc]*) \
Georg Brandle82110f2010-03-13 13:39:46 +0000177 echo "Not building; $(DISTVERSION) is not a release version."; \
178 exit 1;; \
Georg Brandl34465832010-03-13 10:12:39 +0000179 esac
180 @make autobuild-dev