blob: be05d4b1d9bfd293b6300976a1a7575d407e4bfa [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 Brandl267acd22008-09-21 10:03:39 +000017.PHONY: help checkout update build html htmlhelp clean coverage dist
Georg Brandl8ec7f652007-08-15 14:28:01 +000018
19help:
20 @echo "Please use \`make <target>' where <target> is one of"
Georg Brandlcd235272008-02-01 15:50:15 +000021 @echo " html to make standalone HTML files"
Georg Brandlcd235272008-02-01 15:50:15 +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 Brandl4f2c9982008-06-01 16:41:31 +000024 @echo " text to make plain text files"
Georg Brandlcd235272008-02-01 15:50:15 +000025 @echo " changes to make an overview over all changed/added/deprecated items"
26 @echo " linkcheck to check all external links for integrity"
Georg Brandl17048282008-02-23 18:47:04 +000027 @echo " coverage to check documentation coverage for library and C API"
Georg Brandl267acd22008-09-21 10:03:39 +000028 @echo " dist to create a \"dist\" directory with archived docs for download"
Georg Brandl8ec7f652007-08-15 14:28:01 +000029
30checkout:
31 @if [ ! -d tools/sphinx ]; then \
32 echo "Checking out Sphinx..."; \
33 svn checkout $(SVNROOT)/doctools/trunk/sphinx tools/sphinx; \
34 fi
35 @if [ ! -d tools/docutils ]; then \
36 echo "Checking out Docutils..."; \
Georg Brandlaa7c8bd2008-06-26 21:12:55 +000037 svn checkout $(SVNROOT)/external/docutils-0.5/docutils tools/docutils; \
Georg Brandl8ec7f652007-08-15 14:28:01 +000038 fi
Georg Brandl8ffb5732008-04-13 20:51:27 +000039 @if [ ! -d tools/jinja ]; then \
40 echo "Checking out Jinja..."; \
Georg Brandlaa7c8bd2008-06-26 21:12:55 +000041 svn checkout $(SVNROOT)/external/Jinja-1.2/jinja tools/jinja; \
Georg Brandl8ffb5732008-04-13 20:51:27 +000042 fi
Georg Brandl8ec7f652007-08-15 14:28:01 +000043 @if [ ! -d tools/pygments ]; then \
44 echo "Checking out Pygments..."; \
Benjamin Peterson9ba7a302008-09-09 23:16:48 +000045 svn checkout $(SVNROOT)/external/Pygments-0.11.1/pygments tools/pygments; \
Georg Brandl8ec7f652007-08-15 14:28:01 +000046 fi
47
Martin v. Löwis39942402007-09-10 13:19:10 +000048update: checkout
Georg Brandl8ec7f652007-08-15 14:28:01 +000049 svn update tools/sphinx
50 svn update tools/docutils
Georg Brandl8ffb5732008-04-13 20:51:27 +000051 svn update tools/jinja
Georg Brandl8ec7f652007-08-15 14:28:01 +000052 svn update tools/pygments
53
54build: checkout
55 mkdir -p build/$(BUILDER) build/doctrees
56 $(PYTHON) tools/sphinx-build.py $(ALLSPHINXOPTS)
57 @echo
58
59html: BUILDER = html
60html: build
61 @echo "Build finished. The HTML pages are in build/html."
62
Georg Brandl8ec7f652007-08-15 14:28:01 +000063htmlhelp: BUILDER = htmlhelp
64htmlhelp: build
65 @echo "Build finished; now you can run HTML Help Workshop with the" \
Georg Brandl09a5c3e2007-08-15 18:30:42 +000066 "build/htmlhelp/pydoc.hhp project file."
Georg Brandl8ec7f652007-08-15 14:28:01 +000067
Georg Brandl584265b2007-12-02 14:58:50 +000068latex: BUILDER = latex
69latex: build
70 @echo "Build finished; the LaTeX files are in build/latex."
Georg Brandleee1fc52007-12-16 19:36:51 +000071 @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
72 "run these through (pdf)latex."
Georg Brandl584265b2007-12-02 14:58:50 +000073
Georg Brandl4f2c9982008-06-01 16:41:31 +000074text: BUILDER = text
75text: build
76 @echo "Build finished; the text files are in build/text."
77
Georg Brandlb19be572007-12-29 10:57:00 +000078changes: BUILDER = changes
79changes: build
80 @echo "The overview file is in build/changes."
81
Georg Brandlcd235272008-02-01 15:50:15 +000082linkcheck: BUILDER = linkcheck
83linkcheck: build
Georg Brandl17048282008-02-23 18:47:04 +000084 @echo "Link check complete; look for any errors in the above output " \
Georg Brandl7be67ff2008-02-01 19:24:01 +000085 "or in build/$(BUILDER)/output.txt"
Georg Brandlcd235272008-02-01 15:50:15 +000086
Georg Brandl17048282008-02-23 18:47:04 +000087coverage: BUILDER = coverage
88coverage: build
89 @echo "Coverage finished; see c.txt and python.txt in build/coverage"
90
Georg Brandl17baef02008-03-22 10:56:23 +000091doctest: BUILDER = doctest
92doctest: build
93 @echo "Testing of doctests in the sources finished, look at the " \
94 "results in build/doctest/output.txt"
95
Georg Brandl681001e2008-06-01 20:33:55 +000096pydoc-topics: BUILDER = pydoc-topics
97pydoc-topics: build
98 @echo "Building finished; now copy build/pydoc-topics/pydoc_topics.py " \
99 "into the Lib/ directory"
100
Benjamin Petersonb279b8a2008-06-26 21:23:30 +0000101htmlview: html
102 $(PYTHON) -c "import webbrowser; webbrowser.open('build/html/index.html')"
Georg Brandl267acd22008-09-21 10:03:39 +0000103
Georg Brandl8ec7f652007-08-15 14:28:01 +0000104clean:
105 -rm -rf build/*
106 -rm -rf tools/sphinx
Georg Brandl267acd22008-09-21 10:03:39 +0000107
108dist:
109 -rm -rf dist
110 mkdir -p dist
111
112 # archive the HTML
113 make html
Benjamin Petersonf281ff82008-12-21 21:00:53 +0000114 cp -pPR build/html dist/python-$(DISTVERSION)-docs-html
115 tar -C dist -cf dist/python-$(DISTVERSION)-docs-html.tar python-$(DISTVERSION)-docs-html
116 bzip2 -9 -k dist/python-$(DISTVERSION)-docs-html.tar
117 (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-html.zip python-$(DISTVERSION)-docs-html)
118 rm -r dist/python-$(DISTVERSION)-docs-html
119 rm dist/python-$(DISTVERSION)-docs-html.tar
Georg Brandl267acd22008-09-21 10:03:39 +0000120
121 # archive the text build
122 make text
Benjamin Petersonf281ff82008-12-21 21:00:53 +0000123 cp -pPR build/text dist/python-$(DISTVERSION)-docs-text
124 tar -C dist -cf dist/python-$(DISTVERSION)-docs-text.tar python-$(DISTVERSION)-docs-text
125 bzip2 -9 -k dist/python-$(DISTVERSION)-docs-text.tar
126 (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-text.zip python-$(DISTVERSION)-docs-text)
127 rm -r dist/python-$(DISTVERSION)-docs-text
128 rm dist/python-$(DISTVERSION)-docs-text.tar
Georg Brandl267acd22008-09-21 10:03:39 +0000129
130 # archive the A4 latex
131 -rm -r build/latex
132 make latex PAPER=a4
133 (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Petersonf281ff82008-12-21 21:00:53 +0000134 cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-a4.zip
135 cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-a4.tar.bz2
Georg Brandl267acd22008-09-21 10:03:39 +0000136
137 # archive the letter latex
138 rm -r build/latex
139 make latex PAPER=letter
140 (cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
Benjamin Petersonf281ff82008-12-21 21:00:53 +0000141 cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-letter.zip
142 cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-letter.tar.bz2
Georg Brandl267acd22008-09-21 10:03:39 +0000143