##// END OF EJS Templates
gh-pages.py no longer updates index.rst
MinRK -
Show More
@@ -1,111 +1,107 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
9
10 # Internal variables.
10 # Internal variables.
11 PAPEROPT_a4 = -D latex_paper_size=a4
11 PAPEROPT_a4 = -D latex_paper_size=a4
12 PAPEROPT_letter = -D latex_paper_size=letter
12 PAPEROPT_letter = -D latex_paper_size=letter
13 ALLSPHINXOPTS = -d build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(SRCDIR)
13 ALLSPHINXOPTS = -d build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(SRCDIR)
14
14
15 .PHONY: help clean html web pickle htmlhelp latex changes linkcheck api
15 .PHONY: help clean html web pickle htmlhelp latex changes linkcheck api
16
16
17 default: html
17 default: html
18
18
19 help:
19 help:
20 @echo "Please use \`make <target>' where <target> is one of"
20 @echo "Please use \`make <target>' where <target> is one of"
21 @echo " html to make standalone HTML files"
21 @echo " html to make standalone HTML files"
22 @echo " pickle to make pickle files (usable by e.g. sphinx-web)"
22 @echo " pickle to make pickle files (usable by e.g. sphinx-web)"
23 @echo " htmlhelp to make HTML files and a HTML help project"
23 @echo " htmlhelp to make HTML files and a HTML help project"
24 @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
24 @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
25 @echo " changes to make an overview over all changed/added/deprecated items"
25 @echo " changes to make an overview over all changed/added/deprecated items"
26 @echo " linkcheck to check all external links for integrity"
26 @echo " linkcheck to check all external links for integrity"
27 @echo
27 @echo
28 @echo "Compound utility targets:"
28 @echo "Compound utility targets:"
29 @echo "pdf latex and then runs the PDF generation"
29 @echo "pdf latex and then runs the PDF generation"
30 @echo "all html and pdf"
30 @echo "all html and pdf"
31 @echo "dist all, and then puts the results in dist/"
31 @echo "dist all, and then puts the results in dist/"
32 @echo "gitwash-update update git workflow from source repo"
32 @echo "gitwash-update update git workflow from source repo"
33
33
34 clean:
34 clean:
35 -rm -rf build/* dist/* $(SRCDIR)/api/generated
35 -rm -rf build/* dist/* $(SRCDIR)/api/generated
36
36
37 pdf: latex
37 pdf: latex
38 cd build/latex && make all-pdf
38 cd build/latex && make all-pdf
39
39
40 all: html pdf
40 all: html pdf
41
41
42 dist: all
42 dist: all
43 mkdir -p dist
43 mkdir -p dist
44 rm -rf dist/*
44 rm -rf dist/*
45 ln build/latex/ipython.pdf dist/
45 ln build/latex/ipython.pdf dist/
46 cp -al build/html dist/
46 cp -al build/html dist/
47 @echo "Build finished. Final docs are in dist/"
47 @echo "Build finished. Final docs are in dist/"
48
48
49 html: api
49 html: api
50 mkdir -p build/html build/doctrees
50 mkdir -p build/html build/doctrees
51 $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html
51 $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) build/html
52 @echo
52 @echo
53 @echo "Build finished. The HTML pages are in build/html."
53 @echo "Build finished. The HTML pages are in build/html."
54
54
55 api: source/api/generated/gen.txt
55 api: source/api/generated/gen.txt
56
56
57 source/api/generated/gen.txt:
57 source/api/generated/gen.txt:
58 python autogen_api.py
58 python autogen_api.py
59 @echo "Build API docs finished."
59 @echo "Build API docs finished."
60
60
61 pickle:
61 pickle:
62 mkdir -p build/pickle build/doctrees
62 mkdir -p build/pickle build/doctrees
63 $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle
63 $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) build/pickle
64 @echo
64 @echo
65 @echo "Build finished; now you can process the pickle files or run"
65 @echo "Build finished; now you can process the pickle files or run"
66 @echo " sphinx-web build/pickle"
66 @echo " sphinx-web build/pickle"
67 @echo "to start the sphinx-web server."
67 @echo "to start the sphinx-web server."
68
68
69 web: pickle
69 web: pickle
70
70
71 htmlhelp:
71 htmlhelp:
72 mkdir -p build/htmlhelp build/doctrees
72 mkdir -p build/htmlhelp build/doctrees
73 $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp
73 $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) build/htmlhelp
74 @echo
74 @echo
75 @echo "Build finished; now you can run HTML Help Workshop with the" \
75 @echo "Build finished; now you can run HTML Help Workshop with the" \
76 ".hhp project file in build/htmlhelp."
76 ".hhp project file in build/htmlhelp."
77
77
78 latex: api
78 latex: api
79 mkdir -p build/latex build/doctrees
79 mkdir -p build/latex build/doctrees
80 $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex
80 $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) build/latex
81 @echo
81 @echo
82 @echo "Build finished; the LaTeX files are in build/latex."
82 @echo "Build finished; the LaTeX files are in build/latex."
83 @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
83 @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
84 "run these through (pdf)latex."
84 "run these through (pdf)latex."
85
85
86 changes:
86 changes:
87 mkdir -p build/changes build/doctrees
87 mkdir -p build/changes build/doctrees
88 $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes
88 $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) build/changes
89 @echo
89 @echo
90 @echo "The overview file is in build/changes."
90 @echo "The overview file is in build/changes."
91
91
92 linkcheck:
92 linkcheck:
93 mkdir -p build/linkcheck build/doctrees
93 mkdir -p build/linkcheck build/doctrees
94 $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck
94 $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) build/linkcheck
95 @echo
95 @echo
96 @echo "Link check complete; look for any errors in the above output " \
96 @echo "Link check complete; look for any errors in the above output " \
97 "or in build/linkcheck/output.txt."
97 "or in build/linkcheck/output.txt."
98
98
99 gitwash-update:
99 gitwash-update:
100 python ../tools/gitwash_dumper.py source/development ipython
100 python ../tools/gitwash_dumper.py source/development ipython
101 cd source/development/gitwash && rename 's/.rst/.txt/' *.rst
101 cd source/development/gitwash && rename 's/.rst/.txt/' *.rst
102
102
103 nightly: dist
103 nightly: dist
104 rsync -avH --delete dist/ ipython:www/doc/nightly
104 rsync -avH --delete dist/ ipython:www/doc/nightly
105
105
106 gh-pages: html pdf
106 gh-pages: html pdf
107 python gh-pages.py
107 python gh-pages.py
108
109 gh-pages-current: html pdf
110 ipver="$(ipython -v 2>&1)"
111 python gh-pages.py dev "Current Development Version ($ipver)"
@@ -1,168 +1,132 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.getcwd()
72 here = os.getcwd()
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
78 def render_rstindex(fname, tag, desc=None):
79 if desc is None:
80 desc = tag
81
82 rel = '* {d}: `HTML <{t}/index.html>`_ and `PDF <{t}/ipython.pdf>`_.'.format(t=tag,d=desc)
83 rep = re.compile(r'\.\. release')
84 out = []
85 with file(fname) as f:
86 contents = f.read()
87 lines = contents.splitlines()
88 if rel in contents:
89 out = lines
90 else:
91 for line in lines:
92 out.append(line)
93 if rep.search(line):
94 out.append(rep.sub(rel, line))
95 return '\n'.join(out)+'\n'
96
97
98 def new_rstindex(fname, tag, desc=None):
99 new_page = render_rstindex(fname, tag, desc)
100 os.rename(fname, fname+'~')
101 with file(fname, 'w') as f:
102 f.write(new_page)
103
104
105 #-----------------------------------------------------------------------------
77 #-----------------------------------------------------------------------------
106 # Script starts
78 # Script starts
107 #-----------------------------------------------------------------------------
79 #-----------------------------------------------------------------------------
108 if __name__ == '__main__':
80 if __name__ == '__main__':
109 # The tag can be given as a positional argument
81 # The tag can be given as a positional argument
110 try:
82 try:
111 tag = sys.argv[1]
83 tag = sys.argv[1]
112 except IndexError:
84 except IndexError:
113 try:
85 try:
114 tag = sh2('git describe')
86 tag = sh2('git describe')
115 except CalledProcessError:
87 except CalledProcessError:
116 tag = "dev" # Fallback
88 tag = "dev" # Fallback
117
89
118 try:
119 desc = sys.argv[2]
120 except IndexError:
121 desc="Release (%s)"%tag
122
123 startdir = os.getcwd()
90 startdir = os.getcwd()
124 if not os.path.exists(pages_dir):
91 if not os.path.exists(pages_dir):
125 # init the repo
92 # init the repo
126 init_repo(pages_dir)
93 init_repo(pages_dir)
127 else:
94 else:
128 # ensure up-to-date before operating
95 # ensure up-to-date before operating
129 cd(pages_dir)
96 cd(pages_dir)
130 sh('git checkout gh-pages')
97 sh('git checkout gh-pages')
131 sh('git pull')
98 sh('git pull')
132 cd(startdir)
99 cd(startdir)
133
100
134 dest = pjoin(pages_dir, tag)
101 dest = pjoin(pages_dir, tag)
135
102
136 # don't `make html` here, because gh-pages already depends on html in Makefile
103 # don't `make html` here, because gh-pages already depends on html in Makefile
137 # sh('make html')
104 # sh('make html')
138
105
139 # This is pretty unforgiving: we unconditionally nuke the destination
106 # This is pretty unforgiving: we unconditionally nuke the destination
140 # directory, and then copy the html tree in there
107 # directory, and then copy the html tree in there
141 shutil.rmtree(dest, ignore_errors=True)
108 shutil.rmtree(dest, ignore_errors=True)
142 shutil.copytree(html_dir, dest)
109 shutil.copytree(html_dir, dest)
143 shutil.copy(pjoin(pdf_dir, 'ipython.pdf'), pjoin(dest, 'ipython.pdf'))
110 shutil.copy(pjoin(pdf_dir, 'ipython.pdf'), pjoin(dest, 'ipython.pdf'))
144
111
145 try:
112 try:
146 cd(pages_dir)
113 cd(pages_dir)
147 status = sh2('git status | head -1')
114 status = sh2('git status | head -1')
148 branch = re.match('\# On branch (.*)$', status).group(1)
115 branch = re.match('\# On branch (.*)$', status).group(1)
149 if branch != 'gh-pages':
116 if branch != 'gh-pages':
150 e = 'On %r, git branch is %r, MUST be "gh-pages"' % (pages_dir,
117 e = 'On %r, git branch is %r, MUST be "gh-pages"' % (pages_dir,
151 branch)
118 branch)
152 raise RuntimeError(e)
119 raise RuntimeError(e)
153
120
154 sh('git add %s' % tag)
121 sh('git add %s' % tag)
155 new_rstindex('index.rst', tag, desc)
122 sh('git commit -m"Updated doc release: %s"' % tag)
156 sh('python build_index.py')
157 sh('git add index.rst index.html')
158 sh('git commit -m"Created new doc release, named: %s"' % tag)
159 print
123 print
160 print 'Most recent 3 commits:'
124 print 'Most recent 3 commits:'
161 sys.stdout.flush()
125 sys.stdout.flush()
162 sh('git --no-pager log --oneline HEAD~3..')
126 sh('git --no-pager log --oneline HEAD~3..')
163 finally:
127 finally:
164 cd(startdir)
128 cd(startdir)
165
129
166 print
130 print
167 print 'Now verify the build in: %r' % dest
131 print 'Now verify the build in: %r' % dest
168 print "If everything looks good, 'git push'"
132 print "If everything looks good, 'git push'"
@@ -1,165 +1,167 b''
1 .. _documenting-ipython:
1 .. _documenting-ipython:
2
2
3 =====================
3 =====================
4 Documenting IPython
4 Documenting IPython
5 =====================
5 =====================
6
6
7 When contributing code to IPython, you should strive for clarity and
7 When contributing code to IPython, you should strive for clarity and
8 consistency, without falling prey to a style straitjacket. Basically,
8 consistency, without falling prey to a style straitjacket. Basically,
9 'document everything, try to be consistent, do what makes sense.'
9 'document everything, try to be consistent, do what makes sense.'
10
10
11 By and large we follow existing Python practices in major projects like Python
11 By and large we follow existing Python practices in major projects like Python
12 itself or NumPy, this document provides some additional detail for IPython.
12 itself or NumPy, this document provides some additional detail for IPython.
13
13
14
14
15 Standalone documentation
15 Standalone documentation
16 ========================
16 ========================
17
17
18 All standalone documentation should be written in plain text (``.txt``) files
18 All standalone documentation should be written in plain text (``.txt``) files
19 using reStructuredText [reStructuredText]_ for markup and formatting. All such
19 using reStructuredText [reStructuredText]_ for markup and formatting. All such
20 documentation should be placed in the directory :file:`docs/source` of the
20 documentation should be placed in the directory :file:`docs/source` of the
21 IPython source tree. Or, when appropriate, a suitably named subdirectory
21 IPython source tree. Or, when appropriate, a suitably named subdirectory
22 should be used. The documentation in this location will serve as the main
22 should be used. The documentation in this location will serve as the main
23 source for IPython documentation.
23 source for IPython documentation.
24
24
25 The actual HTML and PDF docs are built using the Sphinx [Sphinx]_
25 The actual HTML and PDF docs are built using the Sphinx [Sphinx]_
26 documentation generation tool. Once you have Sphinx installed, you can build
26 documentation generation tool. Once you have Sphinx installed, you can build
27 the html docs yourself by doing:
27 the html docs yourself by doing:
28
28
29 .. code-block:: bash
29 .. code-block:: bash
30
30
31 $ cd ipython-mybranch/docs
31 $ cd ipython-mybranch/docs
32 $ make html
32 $ make html
33
33
34 Our usage of Sphinx follows that of matplotlib [Matplotlib]_ closely. We are
34 Our usage of Sphinx follows that of matplotlib [Matplotlib]_ closely. We are
35 using a number of Sphinx tools and extensions written by the matplotlib team
35 using a number of Sphinx tools and extensions written by the matplotlib team
36 and will mostly follow their conventions, which are nicely spelled out in
36 and will mostly follow their conventions, which are nicely spelled out in
37 their documentation guide [MatplotlibDocGuide]_. What follows is thus a
37 their documentation guide [MatplotlibDocGuide]_. What follows is thus a
38 abridged version of the matplotlib documentation guide, taken with permission
38 abridged version of the matplotlib documentation guide, taken with permission
39 from the matplotlib team.
39 from the matplotlib team.
40
40
41 If you are reading this in a web browser, you can click on the "Show Source"
41 If you are reading this in a web browser, you can click on the "Show Source"
42 link to see the original reStricturedText for the following examples.
42 link to see the original reStricturedText for the following examples.
43
43
44 A bit of Python code::
44 A bit of Python code::
45
45
46 for i in range(10):
46 for i in range(10):
47 print i,
47 print i,
48 print "A big number:",2**34
48 print "A big number:",2**34
49
49
50 An interactive Python session::
50 An interactive Python session::
51
51
52 >>> from IPython.utils.path import get_ipython_dir
52 >>> from IPython.utils.path import get_ipython_dir
53 >>> get_ipython_dir()
53 >>> get_ipython_dir()
54 '/home/fperez/.ipython'
54 '/home/fperez/.ipython'
55
55
56 An IPython session:
56 An IPython session:
57
57
58 .. code-block:: ipython
58 .. code-block:: ipython
59
59
60 In [7]: import IPython
60 In [7]: import IPython
61
61
62 In [8]: print "This IPython is version:",IPython.__version__
62 In [8]: print "This IPython is version:",IPython.__version__
63 This IPython is version: 0.9.1
63 This IPython is version: 0.9.1
64
64
65 In [9]: 2+4
65 In [9]: 2+4
66 Out[9]: 6
66 Out[9]: 6
67
67
68
68
69 A bit of shell code:
69 A bit of shell code:
70
70
71 .. code-block:: bash
71 .. code-block:: bash
72
72
73 cd /tmp
73 cd /tmp
74 echo "My home directory is: $HOME"
74 echo "My home directory is: $HOME"
75 ls
75 ls
76
76
77 Docstring format
77 Docstring format
78 ================
78 ================
79
79
80 Good docstrings are very important. Unfortunately, Python itself only provides
80 Good docstrings are very important. Unfortunately, Python itself only provides
81 a rather loose standard for docstrings [PEP257]_, and there is no universally
81 a rather loose standard for docstrings [PEP257]_, and there is no universally
82 accepted convention for all the different parts of a complete docstring.
82 accepted convention for all the different parts of a complete docstring.
83 However, the NumPy project has established a very reasonable standard, and has
83 However, the NumPy project has established a very reasonable standard, and has
84 developed some tools to support the smooth inclusion of such docstrings in
84 developed some tools to support the smooth inclusion of such docstrings in
85 Sphinx-generated manuals. Rather than inventing yet another pseudo-standard,
85 Sphinx-generated manuals. Rather than inventing yet another pseudo-standard,
86 IPython will be henceforth documented using the NumPy conventions; we carry
86 IPython will be henceforth documented using the NumPy conventions; we carry
87 copies of some of the NumPy support tools to remain self-contained, but share
87 copies of some of the NumPy support tools to remain self-contained, but share
88 back upstream with NumPy any improvements or fixes we may make to the tools.
88 back upstream with NumPy any improvements or fixes we may make to the tools.
89
89
90 The NumPy documentation guidelines [NumPyDocGuide]_ contain detailed
90 The NumPy documentation guidelines [NumPyDocGuide]_ contain detailed
91 information on this standard, and for a quick overview, the NumPy example
91 information on this standard, and for a quick overview, the NumPy example
92 docstring [NumPyExampleDocstring]_ is a useful read.
92 docstring [NumPyExampleDocstring]_ is a useful read.
93
93
94
94
95 For user-facing APIs, we try to be fairly strict about following the above
95 For user-facing APIs, we try to be fairly strict about following the above
96 standards (even though they mean more verbose and detailed docstrings).
96 standards (even though they mean more verbose and detailed docstrings).
97 Wherever you can reasonably expect people to do introspection with::
97 Wherever you can reasonably expect people to do introspection with::
98
98
99 In [1]: some_function?
99 In [1]: some_function?
100
100
101 the docstring should follow the NumPy style and be fairly detailed.
101 the docstring should follow the NumPy style and be fairly detailed.
102
102
103 For purely internal methods that are only likely to be read by others extending
103 For purely internal methods that are only likely to be read by others extending
104 IPython itself we are a bit more relaxed, especially for small/short methods
104 IPython itself we are a bit more relaxed, especially for small/short methods
105 and functions whose intent is reasonably obvious. We still expect docstrings
105 and functions whose intent is reasonably obvious. We still expect docstrings
106 to be written, but they can be simpler. For very short functions with a
106 to be written, but they can be simpler. For very short functions with a
107 single-line docstring you can use something like::
107 single-line docstring you can use something like::
108
108
109 def add(a, b):
109 def add(a, b):
110 """The sum of two numbers.
110 """The sum of two numbers.
111 """
111 """
112 code
112 code
113
113
114 and for longer multiline strings::
114 and for longer multiline strings::
115
115
116 def add(a, b):
116 def add(a, b):
117 """The sum of two numbers.
117 """The sum of two numbers.
118
118
119 Here is the rest of the docs.
119 Here is the rest of the docs.
120 """
120 """
121 code
121 code
122
122
123
123
124 Here are two additional PEPs of interest regarding documentation of code.
124 Here are two additional PEPs of interest regarding documentation of code.
125 While both of these were rejected, the ideas therein form much of the basis of
125 While both of these were rejected, the ideas therein form much of the basis of
126 docutils (the machinery to process reStructuredText):
126 docutils (the machinery to process reStructuredText):
127
127
128 * `Docstring Processing System Framework <http://www.python.org/peps/pep-0256.html>`_
128 * `Docstring Processing System Framework <http://www.python.org/peps/pep-0256.html>`_
129 * `Docutils Design Specification <http://www.python.org/peps/pep-0258.html>`_
129 * `Docutils Design Specification <http://www.python.org/peps/pep-0258.html>`_
130
130
131 .. note::
131 .. note::
132
132
133 In the past IPython used epydoc so currently many docstrings still use
133 In the past IPython used epydoc so currently many docstrings still use
134 epydoc conventions. We will update them as we go, but all new code should
134 epydoc conventions. We will update them as we go, but all new code should
135 be documented using the NumPy standard.
135 be documented using the NumPy standard.
136
136
137 Building and uploading
137 Building and uploading
138 ======================
138 ======================
139 The built docs are stored in a separate repository. Through some github magic,
139 The built docs are stored in a separate repository. Through some github magic,
140 they're automatically exposed as a website. It works like this:
140 they're automatically exposed as a website. It works like this:
141
141
142 * You will need to have sphinx and latex installed. In Ubuntu, install
142 * You will need to have sphinx and latex installed. In Ubuntu, install
143 ``texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended``.
143 ``texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended``.
144 Install the latest version of sphinx from PyPI (``pip install sphinx``).
144 Install the latest version of sphinx from PyPI (``pip install sphinx``).
145 * Ensure that the development version of IPython is the first in your system
145 * Ensure that the development version of IPython is the first in your system
146 path. You can either use a virtualenv, or modify your PYTHONPATH.
146 path. You can either use a virtualenv, or modify your PYTHONPATH.
147 * Switch into the docs directory, and run ``make gh-pages``. This will build
147 * Switch into the docs directory, and run ``make gh-pages``. This will build
148 your updated docs as html and pdf, then automatically check out the latest
148 your updated docs as html and pdf, then automatically check out the latest
149 version of the docs repository, copy the built docs into it, and commit your
149 version of the docs repository, copy the built docs into it, and commit your
150 changes.
150 changes.
151 * Open the built docs in a web browser, and check that they're as expected.
151 * Open the built docs in a web browser, and check that they're as expected.
152 * (If rebuilding the docs for the development version, it may have duplicated
152 * (When building the docs for a new tagged release, you will have to add its link to
153 the link to the development version in the homepage. Remove this from
153 index.rst, then run ``python build_index.py`` to update index.html. Commit the
154 index.rst, then run ``python build_index.py`` to update index.html. Commit the
155 change.)
154 change.)
156 * Upload the docs with ``git push``. This only works if you have write access to
155 * Upload the docs with ``git push``. This only works if you have write access to
157 the docs repository.
156 the docs repository.
157 * If you are building a version that is not the current dev branch, nor a tagged release,
158 then you must run gh-pages.py directly with ``python gh-pages.py <version>``, and *not*
159 with ``make gh-pages``.
158
160
159 .. [reStructuredText] reStructuredText. http://docutils.sourceforge.net/rst.html
161 .. [reStructuredText] reStructuredText. http://docutils.sourceforge.net/rst.html
160 .. [Sphinx] Sphinx. http://sphinx.pocoo.org/
162 .. [Sphinx] Sphinx. http://sphinx.pocoo.org/
161 .. [MatplotlibDocGuide] http://matplotlib.sourceforge.net/devel/documenting_mpl.html
163 .. [MatplotlibDocGuide] http://matplotlib.sourceforge.net/devel/documenting_mpl.html
162 .. [PEP257] PEP 257. http://www.python.org/peps/pep-0257.html
164 .. [PEP257] PEP 257. http://www.python.org/peps/pep-0257.html
163 .. [NumPyDocGuide] NumPy documentation guide. http://projects.scipy.org/numpy/wiki/CodingStyleGuidelines
165 .. [NumPyDocGuide] NumPy documentation guide. http://projects.scipy.org/numpy/wiki/CodingStyleGuidelines
164 .. [NumPyExampleDocstring] NumPy example docstring. http://projects.scipy.org/numpy/browser/trunk/doc/EXAMPLE_DOCSTRING.txt
166 .. [NumPyExampleDocstring] NumPy example docstring. http://projects.scipy.org/numpy/browser/trunk/doc/EXAMPLE_DOCSTRING.txt
165
167
General Comments 0
You need to be logged in to leave comments. Login now