Show More
@@ -0,0 +1,143 | |||
|
1 | #!/usr/bin/env python | |
|
2 | """Script to commit the doc build outputs into the github-pages repo. | |
|
3 | ||
|
4 | Use: | |
|
5 | ||
|
6 | gh-pages.py [tag] | |
|
7 | ||
|
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. | |
|
10 | ||
|
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 """ | |
|
13 | ||
|
14 | #----------------------------------------------------------------------------- | |
|
15 | # Imports | |
|
16 | #----------------------------------------------------------------------------- | |
|
17 | import os | |
|
18 | import re | |
|
19 | import shutil | |
|
20 | import sys | |
|
21 | from os import chdir as cd | |
|
22 | from os.path import join as pjoin | |
|
23 | ||
|
24 | from subprocess import Popen, PIPE, CalledProcessError, check_call | |
|
25 | ||
|
26 | #----------------------------------------------------------------------------- | |
|
27 | # Globals | |
|
28 | #----------------------------------------------------------------------------- | |
|
29 | ||
|
30 | pages_dir = 'gh-pages' | |
|
31 | html_dir = 'build/html' | |
|
32 | pages_repo = 'git@github.com:ipython/ipython-doc.git' | |
|
33 | ||
|
34 | #----------------------------------------------------------------------------- | |
|
35 | # Functions | |
|
36 | #----------------------------------------------------------------------------- | |
|
37 | def sh(cmd): | |
|
38 | """Execute command in a subshell, return status code.""" | |
|
39 | return check_call(cmd, shell=True) | |
|
40 | ||
|
41 | ||
|
42 | def sh2(cmd): | |
|
43 | """Execute command in a subshell, return stdout. | |
|
44 | ||
|
45 | Stderr is unbuffered from the subshell.x""" | |
|
46 | p = Popen(cmd, stdout=PIPE, shell=True) | |
|
47 | out = p.communicate()[0] | |
|
48 | retcode = p.returncode | |
|
49 | if retcode: | |
|
50 | raise CalledProcessError(retcode, cmd) | |
|
51 | else: | |
|
52 | return out.rstrip() | |
|
53 | ||
|
54 | ||
|
55 | def sh3(cmd): | |
|
56 | """Execute command in a subshell, return stdout, stderr | |
|
57 | ||
|
58 | If anything appears in stderr, print it out to sys.stderr""" | |
|
59 | p = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=True) | |
|
60 | out, err = p.communicate() | |
|
61 | retcode = p.returncode | |
|
62 | if retcode: | |
|
63 | raise CalledProcessError(retcode, cmd) | |
|
64 | else: | |
|
65 | return out.rstrip(), err.rstrip() | |
|
66 | ||
|
67 | ||
|
68 | def init_repo(path): | |
|
69 | """clone the gh-pages repo if we haven't already.""" | |
|
70 | sh("git clone %s %s"%(pages_repo, path)) | |
|
71 | here = os.getcwd() | |
|
72 | cd(path) | |
|
73 | sh('git checkout gh-pages') | |
|
74 | cd(here) | |
|
75 | ||
|
76 | ||
|
77 | def render_htmlindex(fname, tag): | |
|
78 | rel = '<li> Release: <a href="{t}/index.html">{t}</a>'.format(t=tag) | |
|
79 | rep = re.compile('<!-- RELEASE -->') | |
|
80 | out = [] | |
|
81 | with file(fname) as f: | |
|
82 | for line in f: | |
|
83 | out.append(line) | |
|
84 | if rep.search(line): | |
|
85 | out.append(rep.sub(rel, line)) | |
|
86 | return ''.join(out) | |
|
87 | ||
|
88 | ||
|
89 | def new_htmlindex(fname, tag): | |
|
90 | new_page = render_htmlindex(fname, tag) | |
|
91 | os.rename(fname, fname+'~') | |
|
92 | with file(fname, 'w') as f: | |
|
93 | f.write(new_page) | |
|
94 | ||
|
95 | ||
|
96 | #----------------------------------------------------------------------------- | |
|
97 | # Script starts | |
|
98 | #----------------------------------------------------------------------------- | |
|
99 | if __name__ == '__main__': | |
|
100 | # The tag can be given as a positional argument | |
|
101 | try: | |
|
102 | tag = sys.argv[1] | |
|
103 | except IndexError: | |
|
104 | tag = sh2('git describe') | |
|
105 | ||
|
106 | startdir = os.getcwd() | |
|
107 | if not os.path.exists(pages_dir): | |
|
108 | init_repo(pages_dir) | |
|
109 | ||
|
110 | dest = pjoin(pages_dir, tag) | |
|
111 | ||
|
112 | # don't `make html` here, because gh-pages already depends on html in Makefile | |
|
113 | # sh('make html') | |
|
114 | ||
|
115 | # This is pretty unforgiving: we unconditionally nuke the destination | |
|
116 | # directory, and then copy the html tree in there | |
|
117 | shutil.rmtree(dest, ignore_errors=True) | |
|
118 | shutil.copytree(html_dir, dest) | |
|
119 | ||
|
120 | try: | |
|
121 | cd(pages_dir) | |
|
122 | sh('git checkout gh-pages') | |
|
123 | status = sh2('git status | head -1') | |
|
124 | branch = re.match('\# On branch (.*)$', status).group(1) | |
|
125 | if branch != 'gh-pages': | |
|
126 | e = 'On %r, git branch is %r, MUST be "gh-pages"' % (pages_dir, | |
|
127 | branch) | |
|
128 | raise RuntimeError(e) | |
|
129 | ||
|
130 | sh('git add %s' % tag) | |
|
131 | new_htmlindex('index.html', tag) | |
|
132 | sh('git add index.html') | |
|
133 | sh('git commit -m"Created new doc release, named: %s"' % tag) | |
|
134 | ||
|
135 | print 'Most recent 3 commits:' | |
|
136 | sys.stdout.flush() | |
|
137 | sh('git --no-pager log --oneline HEAD~3..') | |
|
138 | finally: | |
|
139 | cd(startdir) | |
|
140 | ||
|
141 | ||
|
142 | print 'Now verify the build in: %r' % dest | |
|
143 | print "If everything looks good, 'git push'" |
@@ -1,107 +1,110 | |||
|
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 |
-rm -rf build/* dist/* $(SRCDIR)/api/generated |
|
|
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 | dist: all |
|
43 | 43 | mkdir -p dist |
|
44 | 44 | rm -rf dist/* |
|
45 | 45 | ln build/latex/ipython.pdf dist/ |
|
46 | 46 | cp -al build/html dist/ |
|
47 | 47 | @echo "Build finished. Final docs are in dist/" |
|
48 | 48 | |
|
49 | 49 | html: api |
|
50 | 50 | mkdir -p build/html build/doctrees |
|
51 | 51 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html |
|
52 | 52 | @echo |
|
53 | 53 | @echo "Build finished. The HTML pages are in build/html." |
|
54 | 54 | |
|
55 | 55 | api: source/api/generated/gen.txt |
|
56 | 56 | |
|
57 | 57 | source/api/generated/gen.txt: |
|
58 | 58 | python autogen_api.py |
|
59 | 59 | @echo "Build API docs finished." |
|
60 | 60 | |
|
61 | 61 | pickle: |
|
62 | 62 | mkdir -p build/pickle build/doctrees |
|
63 | 63 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle |
|
64 | 64 | @echo |
|
65 | 65 | @echo "Build finished; now you can process the pickle files or run" |
|
66 | 66 | @echo " sphinx-web build/pickle" |
|
67 | 67 | @echo "to start the sphinx-web server." |
|
68 | 68 | |
|
69 | 69 | web: pickle |
|
70 | 70 | |
|
71 | 71 | htmlhelp: |
|
72 | 72 | mkdir -p build/htmlhelp build/doctrees |
|
73 | 73 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp |
|
74 | 74 | @echo |
|
75 | 75 | @echo "Build finished; now you can run HTML Help Workshop with the" \ |
|
76 | 76 | ".hhp project file in build/htmlhelp." |
|
77 | 77 | |
|
78 | 78 | latex: api |
|
79 | 79 | mkdir -p build/latex build/doctrees |
|
80 | 80 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex |
|
81 | 81 | @echo |
|
82 | 82 | @echo "Build finished; the LaTeX files are in build/latex." |
|
83 | 83 | @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ |
|
84 | 84 | "run these through (pdf)latex." |
|
85 | 85 | |
|
86 | 86 | changes: |
|
87 | 87 | mkdir -p build/changes build/doctrees |
|
88 | 88 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes |
|
89 | 89 | @echo |
|
90 | 90 | @echo "The overview file is in build/changes." |
|
91 | 91 | |
|
92 | 92 | linkcheck: |
|
93 | 93 | mkdir -p build/linkcheck build/doctrees |
|
94 | 94 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck |
|
95 | 95 | @echo |
|
96 | 96 | @echo "Link check complete; look for any errors in the above output " \ |
|
97 | 97 | "or in build/linkcheck/output.txt." |
|
98 | 98 | |
|
99 | 99 | gitwash-update: |
|
100 | 100 | python ../tools/gitwash_dumper.py source/development ipython |
|
101 | 101 | cd source/development/gitwash && rename 's/.rst/.txt/' *.rst |
|
102 | 102 | |
|
103 | 103 | nightly: dist |
|
104 | 104 | rsync -avH --delete dist/ ipython:www/doc/nightly |
|
105 | 105 | |
|
106 | 106 | gh-pages: html |
|
107 | sh update_ghpages.sh | |
|
107 | python gh-pages.py | |
|
108 | ||
|
109 | gh-pages-current: html | |
|
110 | python gh-pages.py current |
@@ -1,196 +1,195 | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | # |
|
3 | 3 | # IPython documentation build configuration file. |
|
4 | 4 | |
|
5 | 5 | # NOTE: This file has been edited manually from the auto-generated one from |
|
6 | 6 | # sphinx. Do NOT delete and re-generate. If any changes from sphinx are |
|
7 | 7 | # needed, generate a scratch one and merge by hand any new fields needed. |
|
8 | 8 | |
|
9 | 9 | # |
|
10 | 10 | # This file is execfile()d with the current directory set to its containing dir. |
|
11 | 11 | # |
|
12 | 12 | # The contents of this file are pickled, so don't put values in the namespace |
|
13 | 13 | # that aren't pickleable (module imports are okay, they're removed automatically). |
|
14 | 14 | # |
|
15 | 15 | # All configuration values have a default value; values that are commented out |
|
16 | 16 | # serve to show the default value. |
|
17 | 17 | |
|
18 | 18 | import sys, os |
|
19 | 19 | |
|
20 | 20 | # If your extensions are in another directory, add it here. If the directory |
|
21 | 21 | # is relative to the documentation root, use os.path.abspath to make it |
|
22 | 22 | # absolute, like shown here. |
|
23 | 23 | sys.path.insert(0, os.path.abspath('../sphinxext')) |
|
24 | 24 | |
|
25 | 25 | # Import support for ipython console session syntax highlighting (lives |
|
26 | 26 | # in the sphinxext directory defined above) |
|
27 | 27 | import ipython_console_highlighting |
|
28 | 28 | |
|
29 | 29 | # We load the ipython release info into a dict by explicit execution |
|
30 | 30 | iprelease = {} |
|
31 | 31 | execfile('../../IPython/core/release.py',iprelease) |
|
32 | 32 | |
|
33 | 33 | # General configuration |
|
34 | 34 | # --------------------- |
|
35 | 35 | |
|
36 | 36 | # Add any Sphinx extension module names here, as strings. They can be extensions |
|
37 | 37 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. |
|
38 | 38 | extensions = [ |
|
39 | 39 | # 'matplotlib.sphinxext.mathmpl', |
|
40 | 40 | 'matplotlib.sphinxext.only_directives', |
|
41 | 41 | # 'matplotlib.sphinxext.plot_directive', |
|
42 | 42 | 'sphinx.ext.autodoc', |
|
43 | 43 | 'sphinx.ext.doctest', |
|
44 | 44 | 'inheritance_diagram', |
|
45 | 45 | 'ipython_console_highlighting', |
|
46 | 46 | 'numpydoc', # to preprocess docstrings |
|
47 | 'sphinxtogithub', | |
|
48 | 47 | ] |
|
49 | 48 | |
|
50 | 49 | # Add any paths that contain templates here, relative to this directory. |
|
51 | 50 | templates_path = ['_templates'] |
|
52 | 51 | |
|
53 | 52 | # The suffix of source filenames. |
|
54 | 53 | source_suffix = '.txt' |
|
55 | 54 | |
|
56 | 55 | # The master toctree document. |
|
57 | 56 | master_doc = 'index' |
|
58 | 57 | |
|
59 | 58 | # General substitutions. |
|
60 | 59 | project = 'IPython' |
|
61 | 60 | copyright = '2008, The IPython Development Team' |
|
62 | 61 | |
|
63 | 62 | # The default replacements for |version| and |release|, also used in various |
|
64 | 63 | # other places throughout the built documents. |
|
65 | 64 | # |
|
66 | 65 | # The full version, including alpha/beta/rc tags. |
|
67 | 66 | release = iprelease['version'] |
|
68 | 67 | # The short X.Y version. |
|
69 | 68 | version = '.'.join(release.split('.',2)[:2]) |
|
70 | 69 | |
|
71 | 70 | |
|
72 | 71 | # There are two options for replacing |today|: either, you set today to some |
|
73 | 72 | # non-false value, then it is used: |
|
74 | 73 | #today = '' |
|
75 | 74 | # Else, today_fmt is used as the format for a strftime call. |
|
76 | 75 | today_fmt = '%B %d, %Y' |
|
77 | 76 | |
|
78 | 77 | # List of documents that shouldn't be included in the build. |
|
79 | 78 | #unused_docs = [] |
|
80 | 79 | |
|
81 | 80 | # List of directories, relative to source directories, that shouldn't be searched |
|
82 | 81 | # for source files. |
|
83 | 82 | exclude_dirs = ['attic'] |
|
84 | 83 | |
|
85 | 84 | # If true, '()' will be appended to :func: etc. cross-reference text. |
|
86 | 85 | #add_function_parentheses = True |
|
87 | 86 | |
|
88 | 87 | # If true, the current module name will be prepended to all description |
|
89 | 88 | # unit titles (such as .. function::). |
|
90 | 89 | #add_module_names = True |
|
91 | 90 | |
|
92 | 91 | # If true, sectionauthor and moduleauthor directives will be shown in the |
|
93 | 92 | # output. They are ignored by default. |
|
94 | 93 | #show_authors = False |
|
95 | 94 | |
|
96 | 95 | # The name of the Pygments (syntax highlighting) style to use. |
|
97 | 96 | pygments_style = 'sphinx' |
|
98 | 97 | |
|
99 | 98 | |
|
100 | 99 | # Options for HTML output |
|
101 | 100 | # ----------------------- |
|
102 | 101 | |
|
103 | 102 | # The style sheet to use for HTML and HTML Help pages. A file of that name |
|
104 | 103 | # must exist either in Sphinx' static/ path, or in one of the custom paths |
|
105 | 104 | # given in html_static_path. |
|
106 | 105 | html_style = 'default.css' |
|
107 | 106 | |
|
108 | 107 | # The name for this set of Sphinx documents. If None, it defaults to |
|
109 | 108 | # "<project> v<release> documentation". |
|
110 | 109 | #html_title = None |
|
111 | 110 | |
|
112 | 111 | # The name of an image file (within the static path) to place at the top of |
|
113 | 112 | # the sidebar. |
|
114 | 113 | #html_logo = None |
|
115 | 114 | |
|
116 | 115 | # Add any paths that contain custom static files (such as style sheets) here, |
|
117 | 116 | # relative to this directory. They are copied after the builtin static files, |
|
118 | 117 | # so a file named "default.css" will overwrite the builtin "default.css". |
|
119 | 118 | html_static_path = ['_static'] |
|
120 | 119 | |
|
121 | 120 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, |
|
122 | 121 | # using the given strftime format. |
|
123 | 122 | html_last_updated_fmt = '%b %d, %Y' |
|
124 | 123 | |
|
125 | 124 | # If true, SmartyPants will be used to convert quotes and dashes to |
|
126 | 125 | # typographically correct entities. |
|
127 | 126 | #html_use_smartypants = True |
|
128 | 127 | |
|
129 | 128 | # Custom sidebar templates, maps document names to template names. |
|
130 | 129 | #html_sidebars = {} |
|
131 | 130 | |
|
132 | 131 | # Additional templates that should be rendered to pages, maps page names to |
|
133 | 132 | # template names. |
|
134 | 133 | #html_additional_pages = {} |
|
135 | 134 | |
|
136 | 135 | # If false, no module index is generated. |
|
137 | 136 | #html_use_modindex = True |
|
138 | 137 | |
|
139 | 138 | # If true, the reST sources are included in the HTML build as _sources/<name>. |
|
140 | 139 | #html_copy_source = True |
|
141 | 140 | |
|
142 | 141 | # If true, an OpenSearch description file will be output, and all pages will |
|
143 | 142 | # contain a <link> tag referring to it. The value of this option must be the |
|
144 | 143 | # base URL from which the finished HTML is served. |
|
145 | 144 | #html_use_opensearch = '' |
|
146 | 145 | |
|
147 | 146 | # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). |
|
148 | 147 | #html_file_suffix = '' |
|
149 | 148 | |
|
150 | 149 | # Output file base name for HTML help builder. |
|
151 | 150 | htmlhelp_basename = 'ipythondoc' |
|
152 | 151 | |
|
153 | 152 | |
|
154 | 153 | # Options for LaTeX output |
|
155 | 154 | # ------------------------ |
|
156 | 155 | |
|
157 | 156 | # The paper size ('letter' or 'a4'). |
|
158 | 157 | latex_paper_size = 'letter' |
|
159 | 158 | |
|
160 | 159 | # The font size ('10pt', '11pt' or '12pt'). |
|
161 | 160 | latex_font_size = '11pt' |
|
162 | 161 | |
|
163 | 162 | # Grouping the document tree into LaTeX files. List of tuples |
|
164 | 163 | # (source start file, target name, title, author, document class [howto/manual]). |
|
165 | 164 | |
|
166 | 165 | latex_documents = [ |
|
167 | 166 | ('index', 'ipython.tex', 'IPython Documentation', |
|
168 | 167 | ur"""The IPython Development Team""", 'manual', True), |
|
169 | 168 | ('parallel/winhpc_index', 'winhpc_whitepaper.tex', |
|
170 | 169 | 'Using IPython on Windows HPC Server 2008', |
|
171 | 170 | ur"Brian E. Granger", 'manual', True) |
|
172 | 171 | ] |
|
173 | 172 | |
|
174 | 173 | # The name of an image file (relative to this directory) to place at the top of |
|
175 | 174 | # the title page. |
|
176 | 175 | #latex_logo = None |
|
177 | 176 | |
|
178 | 177 | # For "manual" documents, if this is true, then toplevel headings are parts, |
|
179 | 178 | # not chapters. |
|
180 | 179 | #latex_use_parts = False |
|
181 | 180 | |
|
182 | 181 | # Additional stuff for the LaTeX preamble. |
|
183 | 182 | #latex_preamble = '' |
|
184 | 183 | |
|
185 | 184 | # Documents to append as an appendix to all manuals. |
|
186 | 185 | #latex_appendices = [] |
|
187 | 186 | |
|
188 | 187 | # If false, no module index is generated. |
|
189 | 188 | latex_use_modindex = True |
|
190 | 189 | |
|
191 | 190 | |
|
192 | 191 | # Cleanup |
|
193 | 192 | # ------- |
|
194 | 193 | # delete release info to avoid pickling errors from sphinx |
|
195 | 194 | |
|
196 | 195 | del iprelease |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now