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