##// END OF EJS Templates
require specifying the version for gh-pages...
MinRK -
Show More
@@ -1,137 +1,140 b''
1 # Makefile for Sphinx documentation
1 # Makefile for Sphinx documentation
2 #
2 #
3
3
4 # You can set these variables from the command line.
4 # You can set these variables from the command line.
5 SPHINXOPTS =
5 SPHINXOPTS =
6 SPHINXBUILD = sphinx-build
6 SPHINXBUILD = sphinx-build
7 PAPER =
7 PAPER =
8 SRCDIR = source
8 SRCDIR = source
9 BUILDDIR = build
9 BUILDDIR = build
10
10
11 # Internal variables.
11 # Internal variables.
12 PAPEROPT_a4 = -D latex_paper_size=a4
12 PAPEROPT_a4 = -D latex_paper_size=a4
13 PAPEROPT_letter = -D latex_paper_size=letter
13 PAPEROPT_letter = -D latex_paper_size=letter
14 ALLSPHINXOPTS = -d build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(SRCDIR)
14 ALLSPHINXOPTS = -d build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(SRCDIR)
15
15
16 .PHONY: help clean html web pickle htmlhelp latex changes linkcheck api
16 .PHONY: help clean html web pickle htmlhelp latex changes linkcheck api
17
17
18 default: html
18 default: html
19
19
20 help:
20 help:
21 @echo "Please use \`make <target>' where <target> is one of"
21 @echo "Please use \`make <target>' where <target> is one of"
22 @echo " html to make standalone HTML files"
22 @echo " html to make standalone HTML files"
23 @echo " pickle to make pickle files (usable by e.g. sphinx-web)"
23 @echo " pickle to make pickle files (usable by e.g. sphinx-web)"
24 @echo " htmlhelp to make HTML files and a HTML help project"
24 @echo " htmlhelp to make HTML files and a HTML help project"
25 @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
25 @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
26 @echo " texinfo to make Texinfo files"
26 @echo " texinfo to make Texinfo files"
27 @echo " info to make Texinfo files and run them through makeinfo"
27 @echo " info to make Texinfo files and run them through makeinfo"
28 @echo " changes to make an overview over all changed/added/deprecated items"
28 @echo " changes to make an overview over all changed/added/deprecated items"
29 @echo " linkcheck to check all external links for integrity"
29 @echo " linkcheck to check all external links for integrity"
30 @echo
30 @echo
31 @echo "Compound utility targets:"
31 @echo "Compound utility targets:"
32 @echo "pdf latex and then runs the PDF generation"
32 @echo "pdf latex and then runs the PDF generation"
33 @echo "all html and pdf"
33 @echo "all html and pdf"
34 @echo "dist all, and then puts the results in dist/"
34 @echo "dist all, and then puts the results in dist/"
35 @echo "gitwash-update update git workflow from source repo"
35 @echo "gitwash-update update git workflow from source repo"
36
36
37 clean:
37 clean:
38 -rm -rf build/* dist/* $(SRCDIR)/api/generated
38 -rm -rf build/* dist/* $(SRCDIR)/api/generated
39
39
40 pdf: latex
40 pdf: latex
41 cd build/latex && make all-pdf
41 cd build/latex && make all-pdf
42
42
43 all: html pdf
43 all: html pdf
44
44
45 # For final distribution, only build HTML (our pdf is now so large as to be
45 # For final distribution, only build HTML (our pdf is now so large as to be
46 # unusable, takes forever to build and just bloats the downloads). We leave
46 # unusable, takes forever to build and just bloats the downloads). We leave
47 # them hardlinked at the top-level so users find them easily, though the
47 # them hardlinked at the top-level so users find them easily, though the
48 # original build/html dir is left in-place (useful to reload builds while
48 # original build/html dir is left in-place (useful to reload builds while
49 # testing).
49 # testing).
50 dist: html
50 dist: html
51 rm -rf html
51 rm -rf html
52 cp -al build/html .
52 cp -al build/html .
53 @echo "Build finished. Final docs are in html/"
53 @echo "Build finished. Final docs are in html/"
54
54
55 html: api
55 html: api
56 mkdir -p build/html build/doctrees
56 mkdir -p build/html build/doctrees
57 $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html
57 $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html
58 @echo
58 @echo
59 @echo "Build finished. The HTML pages are in build/html."
59 @echo "Build finished. The HTML pages are in build/html."
60
60
61 api: source/api/generated/gen.txt
61 api: source/api/generated/gen.txt
62
62
63 source/api/generated/gen.txt:
63 source/api/generated/gen.txt:
64 python autogen_api.py
64 python autogen_api.py
65 @echo "Build API docs finished."
65 @echo "Build API docs finished."
66
66
67 pickle:
67 pickle:
68 mkdir -p build/pickle build/doctrees
68 mkdir -p build/pickle build/doctrees
69 $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle
69 $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle
70 @echo
70 @echo
71 @echo "Build finished; now you can process the pickle files or run"
71 @echo "Build finished; now you can process the pickle files or run"
72 @echo " sphinx-web build/pickle"
72 @echo " sphinx-web build/pickle"
73 @echo "to start the sphinx-web server."
73 @echo "to start the sphinx-web server."
74
74
75 web: pickle
75 web: pickle
76
76
77 htmlhelp:
77 htmlhelp:
78 mkdir -p build/htmlhelp build/doctrees
78 mkdir -p build/htmlhelp build/doctrees
79 $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp
79 $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp
80 @echo
80 @echo
81 @echo "Build finished; now you can run HTML Help Workshop with the" \
81 @echo "Build finished; now you can run HTML Help Workshop with the" \
82 ".hhp project file in build/htmlhelp."
82 ".hhp project file in build/htmlhelp."
83
83
84 qthelp:
84 qthelp:
85 mkdir -p build/qthelp
85 mkdir -p build/qthelp
86 $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) build/qthelp
86 $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) build/qthelp
87 @echo
87 @echo
88 @echo "Build finished; now you can run "qcollectiongenerator" with the" \
88 @echo "Build finished; now you can run "qcollectiongenerator" with the" \
89 ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
89 ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
90 @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/IPython.qhcp"
90 @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/IPython.qhcp"
91 @echo "To view the help file:"
91 @echo "To view the help file:"
92 @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/IPython.qhc"
92 @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/IPython.qhc"
93
93
94 latex: api
94 latex: api
95 mkdir -p build/latex build/doctrees
95 mkdir -p build/latex build/doctrees
96 $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex
96 $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex
97 @echo
97 @echo
98 @echo "Build finished; the LaTeX files are in build/latex."
98 @echo "Build finished; the LaTeX files are in build/latex."
99 @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
99 @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
100 "run these through (pdf)latex."
100 "run these through (pdf)latex."
101
101
102 changes:
102 changes:
103 mkdir -p build/changes build/doctrees
103 mkdir -p build/changes build/doctrees
104 $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes
104 $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes
105 @echo
105 @echo
106 @echo "The overview file is in build/changes."
106 @echo "The overview file is in build/changes."
107
107
108 linkcheck:
108 linkcheck:
109 mkdir -p build/linkcheck build/doctrees
109 mkdir -p build/linkcheck build/doctrees
110 $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck
110 $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck
111 @echo
111 @echo
112 @echo "Link check complete; look for any errors in the above output " \
112 @echo "Link check complete; look for any errors in the above output " \
113 "or in build/linkcheck/output.rst."
113 "or in build/linkcheck/output.rst."
114
114
115 gitwash-update:
115 gitwash-update:
116 python ../tools/gitwash_dumper.py source/development ipython
116 python ../tools/gitwash_dumper.py source/development ipython
117
117
118 nightly: dist
118 nightly: dist
119 rsync -avH --delete dist/ ipython:www/doc/nightly
119 rsync -avH --delete dist/ ipython:www/doc/nightly
120
120
121 gh-pages: clean html
121 gh-pages: clean html
122 python gh-pages.py
122 # if VERSION is unspecified, it will be dev
123 # For releases, VERSION should be just the major version,
124 # e.g. VERSION=2 make gh-pages
125 python gh-pages.py $(VERSION)
123
126
124 texinfo:
127 texinfo:
125 mkdir -p $(BUILDDIR)/texinfo
128 mkdir -p $(BUILDDIR)/texinfo
126 $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
129 $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
127 @echo
130 @echo
128 @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
131 @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
129 @echo "Run \`make' in that directory to run these through makeinfo" \
132 @echo "Run \`make' in that directory to run these through makeinfo" \
130 "(use \`make info' here to do that automatically)."
133 "(use \`make info' here to do that automatically)."
131
134
132 info:
135 info:
133 mkdir -p $(BUILDDIR)/texinfo
136 mkdir -p $(BUILDDIR)/texinfo
134 $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
137 $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
135 @echo "Running Texinfo files through makeinfo..."
138 @echo "Running Texinfo files through makeinfo..."
136 make -C $(BUILDDIR)/texinfo info
139 make -C $(BUILDDIR)/texinfo info
137 @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
140 @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
@@ -1,138 +1,134 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 """Script to commit the doc build outputs into the github-pages repo.
2 """Script to commit the doc build outputs into the github-pages repo.
3
3
4 Use:
4 Use:
5
5
6 gh-pages.py [tag]
6 gh-pages.py [tag]
7
7
8 If no tag is given, the current output of 'git describe' is used. If given,
8 If no tag is given, the current output of 'git describe' is used. If given,
9 that is how the resulting directory will be named.
9 that is how the resulting directory will be named.
10
10
11 In practice, you should use either actual clean tags from a current build or
11 In practice, you should use either actual clean tags from a current build or
12 something like 'current' as a stable URL for the most current version of the """
12 something like 'current' as a stable URL for the most current version of the """
13
13
14 #-----------------------------------------------------------------------------
14 #-----------------------------------------------------------------------------
15 # Imports
15 # Imports
16 #-----------------------------------------------------------------------------
16 #-----------------------------------------------------------------------------
17 import os
17 import os
18 import re
18 import re
19 import shutil
19 import shutil
20 import sys
20 import sys
21 from os import chdir as cd
21 from os import chdir as cd
22 from os.path import join as pjoin
22 from os.path import join as pjoin
23
23
24 from subprocess import Popen, PIPE, CalledProcessError, check_call
24 from subprocess import Popen, PIPE, CalledProcessError, check_call
25
25
26 #-----------------------------------------------------------------------------
26 #-----------------------------------------------------------------------------
27 # Globals
27 # Globals
28 #-----------------------------------------------------------------------------
28 #-----------------------------------------------------------------------------
29
29
30 pages_dir = 'gh-pages'
30 pages_dir = 'gh-pages'
31 html_dir = 'build/html'
31 html_dir = 'build/html'
32 pdf_dir = 'build/latex'
32 pdf_dir = 'build/latex'
33 pages_repo = 'git@github.com:ipython/ipython-doc.git'
33 pages_repo = 'git@github.com:ipython/ipython-doc.git'
34
34
35 #-----------------------------------------------------------------------------
35 #-----------------------------------------------------------------------------
36 # Functions
36 # Functions
37 #-----------------------------------------------------------------------------
37 #-----------------------------------------------------------------------------
38 def sh(cmd):
38 def sh(cmd):
39 """Execute command in a subshell, return status code."""
39 """Execute command in a subshell, return status code."""
40 return check_call(cmd, shell=True)
40 return check_call(cmd, shell=True)
41
41
42
42
43 def sh2(cmd):
43 def sh2(cmd):
44 """Execute command in a subshell, return stdout.
44 """Execute command in a subshell, return stdout.
45
45
46 Stderr is unbuffered from the subshell.x"""
46 Stderr is unbuffered from the subshell.x"""
47 p = Popen(cmd, stdout=PIPE, shell=True)
47 p = Popen(cmd, stdout=PIPE, shell=True)
48 out = p.communicate()[0]
48 out = p.communicate()[0]
49 retcode = p.returncode
49 retcode = p.returncode
50 if retcode:
50 if retcode:
51 raise CalledProcessError(retcode, cmd)
51 raise CalledProcessError(retcode, cmd)
52 else:
52 else:
53 return out.rstrip()
53 return out.rstrip()
54
54
55
55
56 def sh3(cmd):
56 def sh3(cmd):
57 """Execute command in a subshell, return stdout, stderr
57 """Execute command in a subshell, return stdout, stderr
58
58
59 If anything appears in stderr, print it out to sys.stderr"""
59 If anything appears in stderr, print it out to sys.stderr"""
60 p = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
60 p = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True)
61 out, err = p.communicate()
61 out, err = p.communicate()
62 retcode = p.returncode
62 retcode = p.returncode
63 if retcode:
63 if retcode:
64 raise CalledProcessError(retcode, cmd)
64 raise CalledProcessError(retcode, cmd)
65 else:
65 else:
66 return out.rstrip(), err.rstrip()
66 return out.rstrip(), err.rstrip()
67
67
68
68
69 def init_repo(path):
69 def init_repo(path):
70 """clone the gh-pages repo if we haven't already."""
70 """clone the gh-pages repo if we haven't already."""
71 sh("git clone %s %s"%(pages_repo, path))
71 sh("git clone %s %s"%(pages_repo, path))
72 here = os.getcwdu()
72 here = os.getcwdu()
73 cd(path)
73 cd(path)
74 sh('git checkout gh-pages')
74 sh('git checkout gh-pages')
75 cd(here)
75 cd(here)
76
76
77 #-----------------------------------------------------------------------------
77 #-----------------------------------------------------------------------------
78 # Script starts
78 # Script starts
79 #-----------------------------------------------------------------------------
79 #-----------------------------------------------------------------------------
80 if __name__ == '__main__':
80 if __name__ == '__main__':
81 # The tag can be given as a positional argument
81 # The tag can be given as a positional argument
82 try:
82 try:
83 tag = sys.argv[1]
83 tag = sys.argv[1]
84 except IndexError:
84 except IndexError:
85 try:
85 tag = "dev"
86 tag = sh2('git describe --exact-match')
87 except CalledProcessError:
88 tag = "dev" # Fallback
89
86
90 startdir = os.getcwdu()
87 startdir = os.getcwdu()
91 if not os.path.exists(pages_dir):
88 if not os.path.exists(pages_dir):
92 # init the repo
89 # init the repo
93 init_repo(pages_dir)
90 init_repo(pages_dir)
94 else:
91 else:
95 # ensure up-to-date before operating
92 # ensure up-to-date before operating
96 cd(pages_dir)
93 cd(pages_dir)
97 sh('git checkout gh-pages')
94 sh('git checkout gh-pages')
98 sh('git pull')
95 sh('git pull')
99 cd(startdir)
96 cd(startdir)
100
97
101 dest = pjoin(pages_dir, tag)
98 dest = pjoin(pages_dir, tag)
102
99
103 # don't `make html` here, because gh-pages already depends on html in Makefile
100 # don't `make html` here, because gh-pages already depends on html in Makefile
104 # sh('make html')
101 # sh('make html')
105 if tag != 'dev':
102 if tag != 'dev':
106 # only build pdf for non-dev targets
103 # only build pdf for non-dev targets
107 #sh2('make pdf')
104 #sh2('make pdf')
108 pass
105 pass
109
106
110 # This is pretty unforgiving: we unconditionally nuke the destination
107 # This is pretty unforgiving: we unconditionally nuke the destination
111 # directory, and then copy the html tree in there
108 # directory, and then copy the html tree in there
112 shutil.rmtree(dest, ignore_errors=True)
109 shutil.rmtree(dest, ignore_errors=True)
113 shutil.copytree(html_dir, dest)
110 shutil.copytree(html_dir, dest)
114 if tag != 'dev':
111 if tag != 'dev':
115 #shutil.copy(pjoin(pdf_dir, 'ipython.pdf'), pjoin(dest, 'ipython.pdf'))
112 #shutil.copy(pjoin(pdf_dir, 'ipython.pdf'), pjoin(dest, 'ipython.pdf'))
116 pass
113 pass
117
114
118 try:
115 try:
119 cd(pages_dir)
116 cd(pages_dir)
120 status = sh2('git status | head -1')
117 branch = sh2('git rev-parse --abbrev-ref HEAD').strip()
121 branch = re.match('\# On branch (.*)$', status).group(1)
122 if branch != 'gh-pages':
118 if branch != 'gh-pages':
123 e = 'On %r, git branch is %r, MUST be "gh-pages"' % (pages_dir,
119 e = 'On %r, git branch is %r, MUST be "gh-pages"' % (pages_dir,
124 branch)
120 branch)
125 raise RuntimeError(e)
121 raise RuntimeError(e)
126
122
127 sh('git add -A %s' % tag)
123 sh('git add -A %s' % tag)
128 sh('git commit -m"Updated doc release: %s"' % tag)
124 sh('git commit -m"Updated doc release: %s"' % tag)
129 print
125 print
130 print 'Most recent 3 commits:'
126 print 'Most recent 3 commits:'
131 sys.stdout.flush()
127 sys.stdout.flush()
132 sh('git --no-pager log --oneline HEAD~3..')
128 sh('git --no-pager log --oneline HEAD~3..')
133 finally:
129 finally:
134 cd(startdir)
130 cd(startdir)
135
131
136 print
132 print
137 print 'Now verify the build in: %r' % dest
133 print 'Now verify the build in: %r' % dest
138 print "If everything looks good, 'git push'"
134 print "If everything looks good, 'git push'"
General Comments 0
You need to be logged in to leave comments. Login now