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