blob: c9f3ed69e39e6336766a5507e36118557e42e16b [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 Brandl9f7a3392009-01-03 20:30:15 +000017.PHONY: help checkout update build html htmlhelp clean coverage dist check
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 Brandl700cf282009-01-04 10:23:49 +000027 @echo " suspicious to check for suspicious markup in output text"
Georg Brandl17048282008-02-23 18:47:04 +000028 @echo " coverage to check documentation coverage for library and C API"
Georg Brandl267acd22008-09-21 10:03:39 +000029 @echo " dist to create a \"dist\" directory with archived docs for download"
Georg Brandl8ec7f652007-08-15 14:28:01 +000030
Georg Brandl43819252009-04-26 09:56:44 +000031# Note: if you update versions here, do the same in make.bat and README.txt
Georg Brandl8ec7f652007-08-15 14:28:01 +000032checkout:
33 @if [ ! -d tools/sphinx ]; then \
34 echo "Checking out Sphinx..."; \
Georg Brandl400fd602009-03-28 19:52:58 +000035 svn checkout $(SVNROOT)/external/Sphinx-0.6.1/sphinx tools/sphinx; \
Georg Brandl8ec7f652007-08-15 14:28:01 +000036 fi
37 @if [ ! -d tools/docutils ]; then \
38 echo "Checking out Docutils..."; \
Georg Brandlaa7c8bd2008-06-26 21:12:55 +000039 svn checkout $(SVNROOT)/external/docutils-0.5/docutils tools/docutils; \
Georg Brandl8ec7f652007-08-15 14:28:01 +000040 fi
Benjamin Petersond680d962009-01-04 22:00:18 +000041 @if [ ! -d tools/jinja2 ]; then \
Georg Brandl8ffb5732008-04-13 20:51:27 +000042 echo "Checking out Jinja..."; \
Benjamin Petersond680d962009-01-04 22:00:18 +000043 svn checkout $(SVNROOT)/external/Jinja-2.1.1/jinja2 tools/jinja2; \
Georg Brandl8ffb5732008-04-13 20:51:27 +000044 fi
Georg Brandl8ec7f652007-08-15 14:28:01 +000045 @if [ ! -d tools/pygments ]; then \
46 echo "Checking out Pygments..."; \
Benjamin Peterson9ba7a302008-09-09 23:16:48 +000047 svn checkout $(SVNROOT)/external/Pygments-0.11.1/pygments tools/pygments; \
Georg Brandl8ec7f652007-08-15 14:28:01 +000048 fi
49
Martin v. Löwis39942402007-09-10 13:19:10 +000050update: checkout
Georg Brandl8ec7f652007-08-15 14:28:01 +000051 svn update tools/sphinx
52 svn update tools/docutils
Benjamin Petersond680d962009-01-04 22:00:18 +000053 svn update tools/jinja2
Georg Brandl8ec7f652007-08-15 14:28:01 +000054 svn update tools/pygments
55
56build: checkout
57 mkdir -p build/$(BUILDER) build/doctrees
58 $(PYTHON) tools/sphinx-build.py $(ALLSPHINXOPTS)
59 @echo
60
61html: BUILDER = html
62html: build
63 @echo "Build finished. The HTML pages are in build/html."
64
Georg Brandl8ec7f652007-08-15 14:28:01 +000065htmlhelp: BUILDER = htmlhelp
66htmlhelp: build
67 @echo "Build finished; now you can run HTML Help Workshop with the" \
Georg Brandl09a5c3e2007-08-15 18:30:42 +000068 "build/htmlhelp/pydoc.hhp project file."
Georg Brandl8ec7f652007-08-15 14:28:01 +000069
Georg Brandl584265b2007-12-02 14:58:50 +000070latex: BUILDER = latex
71latex: build
72 @echo "Build finished; the LaTeX files are in build/latex."
Georg Brandleee1fc52007-12-16 19:36:51 +000073 @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
74 "run these through (pdf)latex."
Georg Brandl584265b2007-12-02 14:58:50 +000075
Georg Brandl4f2c9982008-06-01 16:41:31 +000076text: BUILDER = text
77text: build
78 @echo "Build finished; the text files are in build/text."
79
Georg Brandlb19be572007-12-29 10:57:00 +000080changes: BUILDER = changes
81changes: build
82 @echo "The overview file is in build/changes."
83
Georg Brandlcd235272008-02-01 15:50:15 +000084linkcheck: BUILDER = linkcheck
85linkcheck: build
Georg Brandl17048282008-02-23 18:47:04 +000086 @echo "Link check complete; look for any errors in the above output " \
Georg Brandl7be67ff2008-02-01 19:24:01 +000087 "or in build/$(BUILDER)/output.txt"
Georg Brandlcd235272008-02-01 15:50:15 +000088
Georg Brandl700cf282009-01-04 10:23:49 +000089suspicious: BUILDER = suspicious
90suspicious: build
91 @echo "Suspicious check complete; look for any errors in the above output " \
92 "or in build/$(BUILDER)/suspicious.txt"
93
Georg Brandl17048282008-02-23 18:47:04 +000094coverage: BUILDER = coverage
95coverage: build
96 @echo "Coverage finished; see c.txt and python.txt in build/coverage"
97
Georg Brandl17baef02008-03-22 10:56:23 +000098doctest: BUILDER = doctest
99doctest: build
100 @echo "Testing of doctests in the sources finished, look at the " \
101 "results in build/doctest/output.txt"
102
Georg Brandl681001e2008-06-01 20:33:55 +0000103pydoc-topics: BUILDER = pydoc-topics
104pydoc-topics: build
Georg Brandl43819252009-04-26 09:56:44 +0000105 @echo "Building finished; now copy build/pydoc-topics/topics.py " \
106 "to Lib/pydoc_data/topics.py"
Georg Brandl681001e2008-06-01 20:33:55 +0000107
Benjamin Petersonb279b8a2008-06-26 21:23:30 +0000108htmlview: html
109 $(PYTHON) -c "import webbrowser; webbrowser.open('build/html/index.html')"
Georg Brandl267acd22008-09-21 10:03:39 +0000110
Georg Brandl8ec7f652007-08-15 14:28:01 +0000111clean:
112 -rm -rf build/*
113 -rm -rf tools/sphinx
Georg Brandl267acd22008-09-21 10:03:39 +0000114
115dist:
116 -rm -rf dist
117 mkdir -p dist
118
119 # archive the HTML
120 make html
Benjamin Petersonf281ff82008-12-21 21:00:53 +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
Georg Brandl267acd22008-09-21 10:03:39 +0000127
128 # archive the text build
129 make text
Benjamin Petersonf281ff82008-12-21 21:00:53 +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 Brandl43819252009-04-26 09:56:44 +0000136
Georg Brandl267acd22008-09-21 10:03:39 +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 Petersonf281ff82008-12-21 21:00:53 +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
Georg Brandl267acd22008-09-21 10:03:39 +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 Petersonf281ff82008-12-21 21:00:53 +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
Georg Brandl267acd22008-09-21 10:03:39 +0000150
Georg Brandl9f7a3392009-01-03 20:30:15 +0000151check:
Georg Brandl3b62c2f2009-01-03 21:11:58 +0000152 $(PYTHON) tools/rstlint.py -i tools