##// END OF EJS Templates
Merge pull request #2263 from Carreau/rtfd...
Bussonnier Matthias -
r8155:6c1d6d96 merge
parent child Browse files
Show More
@@ -1,200 +1,232 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 #
2 #
3 # IPython documentation build configuration file.
3 # IPython documentation build configuration file.
4
4
5 # NOTE: This file has been edited manually from the auto-generated one from
5 # NOTE: This file has been edited manually from the auto-generated one from
6 # sphinx. Do NOT delete and re-generate. If any changes from sphinx are
6 # sphinx. Do NOT delete and re-generate. If any changes from sphinx are
7 # needed, generate a scratch one and merge by hand any new fields needed.
7 # needed, generate a scratch one and merge by hand any new fields needed.
8
8
9 #
9 #
10 # This file is execfile()d with the current directory set to its containing dir.
10 # This file is execfile()d with the current directory set to its containing dir.
11 #
11 #
12 # The contents of this file are pickled, so don't put values in the namespace
12 # The contents of this file are pickled, so don't put values in the namespace
13 # that aren't pickleable (module imports are okay, they're removed automatically).
13 # that aren't pickleable (module imports are okay, they're removed automatically).
14 #
14 #
15 # All configuration values have a default value; values that are commented out
15 # All configuration values have a default value; values that are commented out
16 # serve to show the default value.
16 # serve to show the default value.
17
17
18 import sys, os
18 import sys, os
19
19
20 ON_RTD = os.environ.get('READTHEDOCS', None) == 'True'
21
22 if ON_RTD:
23 # Mock the presence of matplotlib, which we don't have on RTD
24 # see
25 # http://read-the-docs.readthedocs.org/en/latest/faq.html
26 tags.add('rtd')
27 class Mock(object):
28 def __init__(self, *args, **kwargs):
29 pass
30
31 def __call__(self, *args, **kwargs):
32 return Mock()
33
34 @classmethod
35 def __getattr__(self, name):
36 if name in ('__file__', '__path__'):
37 return '/dev/null'
38 elif name[0] == name[0].upper():
39 return type(name, (), {})
40 else:
41 return Mock()
42
43 MOCK_MODULES = ['matplotlib', 'matplotlib.sphinxext', 'numpy']
44 for mod_name in MOCK_MODULES:
45 sys.modules[mod_name] = Mock()
46
20 # If your extensions are in another directory, add it here. If the directory
47 # If your extensions are in another directory, add it here. If the directory
21 # is relative to the documentation root, use os.path.abspath to make it
48 # is relative to the documentation root, use os.path.abspath to make it
22 # absolute, like shown here.
49 # absolute, like shown here.
23 sys.path.insert(0, os.path.abspath('../sphinxext'))
50 sys.path.insert(0, os.path.abspath('../sphinxext'))
24
51
25 # Import support for ipython console session syntax highlighting (lives
52 # Import support for ipython console session syntax highlighting (lives
26 # in the sphinxext directory defined above)
53 # in the sphinxext directory defined above)
27 import ipython_console_highlighting
54 import ipython_console_highlighting
28
55
29 # We load the ipython release info into a dict by explicit execution
56 # We load the ipython release info into a dict by explicit execution
30 iprelease = {}
57 iprelease = {}
31 execfile('../../IPython/core/release.py',iprelease)
58 execfile('../../IPython/core/release.py',iprelease)
32
59
33 # General configuration
60 # General configuration
34 # ---------------------
61 # ---------------------
35
62
36 # Add any Sphinx extension module names here, as strings. They can be extensions
63 # Add any Sphinx extension module names here, as strings. They can be extensions
37 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
64 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
38 extensions = [
65 extensions = [
39 # 'matplotlib.sphinxext.mathmpl',
66 # 'matplotlib.sphinxext.mathmpl',
40 'matplotlib.sphinxext.only_directives',
67 'matplotlib.sphinxext.only_directives',
41 # 'matplotlib.sphinxext.plot_directive',
68 # 'matplotlib.sphinxext.plot_directive',
42 'sphinx.ext.autodoc',
69 'sphinx.ext.autodoc',
43 'sphinx.ext.doctest',
70 'sphinx.ext.doctest',
44 'inheritance_diagram',
71 'inheritance_diagram',
45 'ipython_console_highlighting',
72 'ipython_console_highlighting',
46 'ipython_directive',
73 'ipython_directive',
47 'numpydoc', # to preprocess docstrings
74 'numpydoc', # to preprocess docstrings
48 'github', # for easy GitHub links
75 'github', # for easy GitHub links
49 ]
76 ]
50
77
78 if ON_RTD:
79 # Remove extensions not currently supported on RTD
80 extensions.remove('matplotlib.sphinxext.only_directives')
81 extensions.remove('ipython_directive')
82
51 # Add any paths that contain templates here, relative to this directory.
83 # Add any paths that contain templates here, relative to this directory.
52 templates_path = ['_templates']
84 templates_path = ['_templates']
53
85
54 # The suffix of source filenames.
86 # The suffix of source filenames.
55 source_suffix = '.txt'
87 source_suffix = '.txt'
56
88
57 # The master toctree document.
89 # The master toctree document.
58 master_doc = 'index'
90 master_doc = 'index'
59
91
60 # General substitutions.
92 # General substitutions.
61 project = 'IPython'
93 project = 'IPython'
62 copyright = '2008, The IPython Development Team'
94 copyright = '2008, The IPython Development Team'
63
95
64 # ghissue config
96 # ghissue config
65 github_project_url = "https://github.com/ipython/ipython"
97 github_project_url = "https://github.com/ipython/ipython"
66
98
67 # The default replacements for |version| and |release|, also used in various
99 # The default replacements for |version| and |release|, also used in various
68 # other places throughout the built documents.
100 # other places throughout the built documents.
69 #
101 #
70 # The full version, including alpha/beta/rc tags.
102 # The full version, including alpha/beta/rc tags.
71 release = iprelease['version']
103 release = iprelease['version']
72 # The short X.Y version.
104 # The short X.Y version.
73 version = '.'.join(release.split('.',2)[:2])
105 version = '.'.join(release.split('.',2)[:2])
74
106
75
107
76 # There are two options for replacing |today|: either, you set today to some
108 # There are two options for replacing |today|: either, you set today to some
77 # non-false value, then it is used:
109 # non-false value, then it is used:
78 #today = ''
110 #today = ''
79 # Else, today_fmt is used as the format for a strftime call.
111 # Else, today_fmt is used as the format for a strftime call.
80 today_fmt = '%B %d, %Y'
112 today_fmt = '%B %d, %Y'
81
113
82 # List of documents that shouldn't be included in the build.
114 # List of documents that shouldn't be included in the build.
83 #unused_docs = []
115 #unused_docs = []
84
116
85 # List of directories, relative to source directories, that shouldn't be searched
117 # List of directories, relative to source directories, that shouldn't be searched
86 # for source files.
118 # for source files.
87 exclude_dirs = ['attic']
119 exclude_dirs = ['attic']
88
120
89 # If true, '()' will be appended to :func: etc. cross-reference text.
121 # If true, '()' will be appended to :func: etc. cross-reference text.
90 #add_function_parentheses = True
122 #add_function_parentheses = True
91
123
92 # If true, the current module name will be prepended to all description
124 # If true, the current module name will be prepended to all description
93 # unit titles (such as .. function::).
125 # unit titles (such as .. function::).
94 #add_module_names = True
126 #add_module_names = True
95
127
96 # If true, sectionauthor and moduleauthor directives will be shown in the
128 # If true, sectionauthor and moduleauthor directives will be shown in the
97 # output. They are ignored by default.
129 # output. They are ignored by default.
98 #show_authors = False
130 #show_authors = False
99
131
100 # The name of the Pygments (syntax highlighting) style to use.
132 # The name of the Pygments (syntax highlighting) style to use.
101 pygments_style = 'sphinx'
133 pygments_style = 'sphinx'
102
134
103
135
104 # Options for HTML output
136 # Options for HTML output
105 # -----------------------
137 # -----------------------
106
138
107 # The style sheet to use for HTML and HTML Help pages. A file of that name
139 # The style sheet to use for HTML and HTML Help pages. A file of that name
108 # must exist either in Sphinx' static/ path, or in one of the custom paths
140 # must exist either in Sphinx' static/ path, or in one of the custom paths
109 # given in html_static_path.
141 # given in html_static_path.
110 html_style = 'default.css'
142 html_style = 'default.css'
111
143
112 # The name for this set of Sphinx documents. If None, it defaults to
144 # The name for this set of Sphinx documents. If None, it defaults to
113 # "<project> v<release> documentation".
145 # "<project> v<release> documentation".
114 #html_title = None
146 #html_title = None
115
147
116 # The name of an image file (within the static path) to place at the top of
148 # The name of an image file (within the static path) to place at the top of
117 # the sidebar.
149 # the sidebar.
118 #html_logo = None
150 #html_logo = None
119
151
120 # Add any paths that contain custom static files (such as style sheets) here,
152 # Add any paths that contain custom static files (such as style sheets) here,
121 # relative to this directory. They are copied after the builtin static files,
153 # relative to this directory. They are copied after the builtin static files,
122 # so a file named "default.css" will overwrite the builtin "default.css".
154 # so a file named "default.css" will overwrite the builtin "default.css".
123 html_static_path = ['_static']
155 html_static_path = ['_static']
124
156
125 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
157 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
126 # using the given strftime format.
158 # using the given strftime format.
127 html_last_updated_fmt = '%b %d, %Y'
159 html_last_updated_fmt = '%b %d, %Y'
128
160
129 # If true, SmartyPants will be used to convert quotes and dashes to
161 # If true, SmartyPants will be used to convert quotes and dashes to
130 # typographically correct entities.
162 # typographically correct entities.
131 #html_use_smartypants = True
163 #html_use_smartypants = True
132
164
133 # Custom sidebar templates, maps document names to template names.
165 # Custom sidebar templates, maps document names to template names.
134 #html_sidebars = {}
166 #html_sidebars = {}
135
167
136 # Additional templates that should be rendered to pages, maps page names to
168 # Additional templates that should be rendered to pages, maps page names to
137 # template names.
169 # template names.
138 #html_additional_pages = {}
170 #html_additional_pages = {}
139
171
140 # If false, no module index is generated.
172 # If false, no module index is generated.
141 #html_use_modindex = True
173 #html_use_modindex = True
142
174
143 # If true, the reST sources are included in the HTML build as _sources/<name>.
175 # If true, the reST sources are included in the HTML build as _sources/<name>.
144 #html_copy_source = True
176 #html_copy_source = True
145
177
146 # If true, an OpenSearch description file will be output, and all pages will
178 # If true, an OpenSearch description file will be output, and all pages will
147 # contain a <link> tag referring to it. The value of this option must be the
179 # contain a <link> tag referring to it. The value of this option must be the
148 # base URL from which the finished HTML is served.
180 # base URL from which the finished HTML is served.
149 #html_use_opensearch = ''
181 #html_use_opensearch = ''
150
182
151 # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
183 # If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
152 #html_file_suffix = ''
184 #html_file_suffix = ''
153
185
154 # Output file base name for HTML help builder.
186 # Output file base name for HTML help builder.
155 htmlhelp_basename = 'ipythondoc'
187 htmlhelp_basename = 'ipythondoc'
156
188
157
189
158 # Options for LaTeX output
190 # Options for LaTeX output
159 # ------------------------
191 # ------------------------
160
192
161 # The paper size ('letter' or 'a4').
193 # The paper size ('letter' or 'a4').
162 latex_paper_size = 'letter'
194 latex_paper_size = 'letter'
163
195
164 # The font size ('10pt', '11pt' or '12pt').
196 # The font size ('10pt', '11pt' or '12pt').
165 latex_font_size = '11pt'
197 latex_font_size = '11pt'
166
198
167 # Grouping the document tree into LaTeX files. List of tuples
199 # Grouping the document tree into LaTeX files. List of tuples
168 # (source start file, target name, title, author, document class [howto/manual]).
200 # (source start file, target name, title, author, document class [howto/manual]).
169
201
170 latex_documents = [
202 latex_documents = [
171 ('index', 'ipython.tex', 'IPython Documentation',
203 ('index', 'ipython.tex', 'IPython Documentation',
172 ur"""The IPython Development Team""", 'manual', True),
204 ur"""The IPython Development Team""", 'manual', True),
173 ('parallel/winhpc_index', 'winhpc_whitepaper.tex',
205 ('parallel/winhpc_index', 'winhpc_whitepaper.tex',
174 'Using IPython on Windows HPC Server 2008',
206 'Using IPython on Windows HPC Server 2008',
175 ur"Brian E. Granger", 'manual', True)
207 ur"Brian E. Granger", 'manual', True)
176 ]
208 ]
177
209
178 # The name of an image file (relative to this directory) to place at the top of
210 # The name of an image file (relative to this directory) to place at the top of
179 # the title page.
211 # the title page.
180 #latex_logo = None
212 #latex_logo = None
181
213
182 # For "manual" documents, if this is true, then toplevel headings are parts,
214 # For "manual" documents, if this is true, then toplevel headings are parts,
183 # not chapters.
215 # not chapters.
184 #latex_use_parts = False
216 #latex_use_parts = False
185
217
186 # Additional stuff for the LaTeX preamble.
218 # Additional stuff for the LaTeX preamble.
187 #latex_preamble = ''
219 #latex_preamble = ''
188
220
189 # Documents to append as an appendix to all manuals.
221 # Documents to append as an appendix to all manuals.
190 #latex_appendices = []
222 #latex_appendices = []
191
223
192 # If false, no module index is generated.
224 # If false, no module index is generated.
193 latex_use_modindex = True
225 latex_use_modindex = True
194
226
195
227
196 # Cleanup
228 # Cleanup
197 # -------
229 # -------
198 # delete release info to avoid pickling errors from sphinx
230 # delete release info to avoid pickling errors from sphinx
199
231
200 del iprelease
232 del iprelease
@@ -1,419 +1,419 b''
1 .. _ipython_directive:
1 .. _ipython_directive:
2
2
3 ========================
3 ========================
4 Ipython Sphinx Directive
4 IPython Sphinx Directive
5 ========================
5 ========================
6
6
7 The ipython directive is a stateful ipython shell for embedding in
7 The ipython directive is a stateful ipython shell for embedding in
8 sphinx documents. It knows about standard ipython prompts, and
8 sphinx documents. It knows about standard ipython prompts, and
9 extracts the input and output lines. These prompts will be renumbered
9 extracts the input and output lines. These prompts will be renumbered
10 starting at ``1``. The inputs will be fed to an embedded ipython
10 starting at ``1``. The inputs will be fed to an embedded ipython
11 interpreter and the outputs from that interpreter will be inserted as
11 interpreter and the outputs from that interpreter will be inserted as
12 well. For example, code blocks like the following::
12 well. For example, code blocks like the following::
13
13
14 .. ipython::
14 .. ipython::
15
15
16 In [136]: x = 2
16 In [136]: x = 2
17
17
18 In [137]: x**3
18 In [137]: x**3
19 Out[137]: 8
19 Out[137]: 8
20
20
21 will be rendered as
21 will be rendered as
22
22
23 .. ipython::
23 .. ipython::
24
24
25 In [136]: x = 2
25 In [136]: x = 2
26
26
27 In [137]: x**3
27 In [137]: x**3
28 Out[137]: 8
28 Out[137]: 8
29
29
30 .. note::
30 .. note::
31
31
32 This tutorial should be read side-by-side with the Sphinx source
32 This tutorial should be read side-by-side with the Sphinx source
33 for this document because otherwise you will see only the rendered
33 for this document because otherwise you will see only the rendered
34 output and not the code that generated it. Excepting the example
34 output and not the code that generated it. Excepting the example
35 above, we will not in general be showing the literal ReST in this
35 above, we will not in general be showing the literal ReST in this
36 document that generates the rendered output.
36 document that generates the rendered output.
37
37
38
38
39 The state from previous sessions is stored, and standard error is
39 The state from previous sessions is stored, and standard error is
40 trapped. At doc build time, ipython's output and std err will be
40 trapped. At doc build time, ipython's output and std err will be
41 inserted, and prompts will be renumbered. So the prompt below should
41 inserted, and prompts will be renumbered. So the prompt below should
42 be renumbered in the rendered docs, and pick up where the block above
42 be renumbered in the rendered docs, and pick up where the block above
43 left off.
43 left off.
44
44
45 .. ipython::
45 .. ipython::
46
46
47 In [138]: z = x*3 # x is recalled from previous block
47 In [138]: z = x*3 # x is recalled from previous block
48
48
49 In [139]: z
49 In [139]: z
50 Out[139]: 6
50 Out[139]: 6
51
51
52 In [140]: print z
52 In [140]: print z
53 --------> print(z)
53 --------> print(z)
54 6
54 6
55
55
56 In [141]: q = z[) # this is a syntax error -- we trap ipy exceptions
56 In [141]: q = z[) # this is a syntax error -- we trap ipy exceptions
57 ------------------------------------------------------------
57 ------------------------------------------------------------
58 File "<ipython console>", line 1
58 File "<ipython console>", line 1
59 q = z[) # this is a syntax error -- we trap ipy exceptions
59 q = z[) # this is a syntax error -- we trap ipy exceptions
60 ^
60 ^
61 SyntaxError: invalid syntax
61 SyntaxError: invalid syntax
62
62
63
63
64 The embedded interpreter supports some limited markup. For example,
64 The embedded interpreter supports some limited markup. For example,
65 you can put comments in your ipython sessions, which are reported
65 you can put comments in your ipython sessions, which are reported
66 verbatim. There are some handy "pseudo-decorators" that let you
66 verbatim. There are some handy "pseudo-decorators" that let you
67 doctest the output. The inputs are fed to an embedded ipython
67 doctest the output. The inputs are fed to an embedded ipython
68 session and the outputs from the ipython session are inserted into
68 session and the outputs from the ipython session are inserted into
69 your doc. If the output in your doc and in the ipython session don't
69 your doc. If the output in your doc and in the ipython session don't
70 match on a doctest assertion, an error will be
70 match on a doctest assertion, an error will be
71
71
72
72
73 .. ipython::
73 .. ipython::
74
74
75 In [1]: x = 'hello world'
75 In [1]: x = 'hello world'
76
76
77 # this will raise an error if the ipython output is different
77 # this will raise an error if the ipython output is different
78 @doctest
78 @doctest
79 In [2]: x.upper()
79 In [2]: x.upper()
80 Out[2]: 'HELLO WORLD'
80 Out[2]: 'HELLO WORLD'
81
81
82 # some readline features cannot be supported, so we allow
82 # some readline features cannot be supported, so we allow
83 # "verbatim" blocks, which are dumped in verbatim except prompts
83 # "verbatim" blocks, which are dumped in verbatim except prompts
84 # are continuously numbered
84 # are continuously numbered
85 @verbatim
85 @verbatim
86 In [3]: x.st<TAB>
86 In [3]: x.st<TAB>
87 x.startswith x.strip
87 x.startswith x.strip
88
88
89
89
90 Multi-line input is supported.
90 Multi-line input is supported.
91
91
92 .. ipython::
92 .. ipython::
93
93
94 In [130]: url = 'http://ichart.finance.yahoo.com/table.csv?s=CROX\
94 In [130]: url = 'http://ichart.finance.yahoo.com/table.csv?s=CROX\
95 .....: &d=9&e=22&f=2009&g=d&a=1&br=8&c=2006&ignore=.csv'
95 .....: &d=9&e=22&f=2009&g=d&a=1&br=8&c=2006&ignore=.csv'
96
96
97 In [131]: print url.split('&')
97 In [131]: print url.split('&')
98 --------> print(url.split('&'))
98 --------> print(url.split('&'))
99 ['http://ichart.finance.yahoo.com/table.csv?s=CROX', 'd=9', 'e=22',
99 ['http://ichart.finance.yahoo.com/table.csv?s=CROX', 'd=9', 'e=22',
100
100
101 You can do doctesting on multi-line output as well. Just be careful
101 You can do doctesting on multi-line output as well. Just be careful
102 when using non-deterministic inputs like random numbers in the ipython
102 when using non-deterministic inputs like random numbers in the ipython
103 directive, because your inputs are ruin through a live interpreter, so
103 directive, because your inputs are ruin through a live interpreter, so
104 if you are doctesting random output you will get an error. Here we
104 if you are doctesting random output you will get an error. Here we
105 "seed" the random number generator for deterministic output, and we
105 "seed" the random number generator for deterministic output, and we
106 suppress the seed line so it doesn't show up in the rendered output
106 suppress the seed line so it doesn't show up in the rendered output
107
107
108 .. ipython::
108 .. ipython::
109
109
110 In [133]: import numpy.random
110 In [133]: import numpy.random
111
111
112 @suppress
112 @suppress
113 In [134]: numpy.random.seed(2358)
113 In [134]: numpy.random.seed(2358)
114
114
115 @doctest
115 @doctest
116 In [135]: numpy.random.rand(10,2)
116 In [135]: numpy.random.rand(10,2)
117 Out[135]:
117 Out[135]:
118 array([[ 0.64524308, 0.59943846],
118 array([[ 0.64524308, 0.59943846],
119 [ 0.47102322, 0.8715456 ],
119 [ 0.47102322, 0.8715456 ],
120 [ 0.29370834, 0.74776844],
120 [ 0.29370834, 0.74776844],
121 [ 0.99539577, 0.1313423 ],
121 [ 0.99539577, 0.1313423 ],
122 [ 0.16250302, 0.21103583],
122 [ 0.16250302, 0.21103583],
123 [ 0.81626524, 0.1312433 ],
123 [ 0.81626524, 0.1312433 ],
124 [ 0.67338089, 0.72302393],
124 [ 0.67338089, 0.72302393],
125 [ 0.7566368 , 0.07033696],
125 [ 0.7566368 , 0.07033696],
126 [ 0.22591016, 0.77731835],
126 [ 0.22591016, 0.77731835],
127 [ 0.0072729 , 0.34273127]])
127 [ 0.0072729 , 0.34273127]])
128
128
129
129
130 Another demonstration of multi-line input and output
130 Another demonstration of multi-line input and output
131
131
132 .. ipython::
132 .. ipython::
133
133
134 In [106]: print x
134 In [106]: print x
135 --------> print(x)
135 --------> print(x)
136 jdh
136 jdh
137
137
138 In [109]: for i in range(10):
138 In [109]: for i in range(10):
139 .....: print i
139 .....: print i
140 .....:
140 .....:
141 .....:
141 .....:
142 0
142 0
143 1
143 1
144 2
144 2
145 3
145 3
146 4
146 4
147 5
147 5
148 6
148 6
149 7
149 7
150 8
150 8
151 9
151 9
152
152
153
153
154 Most of the "pseudo-decorators" can be used an options to ipython
154 Most of the "pseudo-decorators" can be used an options to ipython
155 mode. For example, to setup matplotlib pylab but suppress the output,
155 mode. For example, to setup matplotlib pylab but suppress the output,
156 you can do. When using the matplotlib ``use`` directive, it should
156 you can do. When using the matplotlib ``use`` directive, it should
157 occur before any import of pylab. This will not show up in the
157 occur before any import of pylab. This will not show up in the
158 rendered docs, but the commands will be executed in the embedded
158 rendered docs, but the commands will be executed in the embedded
159 interpreter and subsequent line numbers will be incremented to reflect
159 interpreter and subsequent line numbers will be incremented to reflect
160 the inputs::
160 the inputs::
161
161
162
162
163 .. ipython::
163 .. ipython::
164 :suppress:
164 :suppress:
165
165
166 In [144]: from pylab import *
166 In [144]: from pylab import *
167
167
168 In [145]: ion()
168 In [145]: ion()
169
169
170 .. ipython::
170 .. ipython::
171 :suppress:
171 :suppress:
172
172
173 In [144]: from pylab import *
173 In [144]: from pylab import *
174
174
175 In [145]: ion()
175 In [145]: ion()
176
176
177 Likewise, you can set ``:doctest:`` or ``:verbatim:`` to apply these
177 Likewise, you can set ``:doctest:`` or ``:verbatim:`` to apply these
178 settings to the entire block. For example,
178 settings to the entire block. For example,
179
179
180 .. ipython::
180 .. ipython::
181 :verbatim:
181 :verbatim:
182
182
183 In [9]: cd mpl/examples/
183 In [9]: cd mpl/examples/
184 /home/jdhunter/mpl/examples
184 /home/jdhunter/mpl/examples
185
185
186 In [10]: pwd
186 In [10]: pwd
187 Out[10]: '/home/jdhunter/mpl/examples'
187 Out[10]: '/home/jdhunter/mpl/examples'
188
188
189
189
190 In [14]: cd mpl/examples/<TAB>
190 In [14]: cd mpl/examples/<TAB>
191 mpl/examples/animation/ mpl/examples/misc/
191 mpl/examples/animation/ mpl/examples/misc/
192 mpl/examples/api/ mpl/examples/mplot3d/
192 mpl/examples/api/ mpl/examples/mplot3d/
193 mpl/examples/axes_grid/ mpl/examples/pylab_examples/
193 mpl/examples/axes_grid/ mpl/examples/pylab_examples/
194 mpl/examples/event_handling/ mpl/examples/widgets
194 mpl/examples/event_handling/ mpl/examples/widgets
195
195
196 In [14]: cd mpl/examples/widgets/
196 In [14]: cd mpl/examples/widgets/
197 /home/msierig/mpl/examples/widgets
197 /home/msierig/mpl/examples/widgets
198
198
199 In [15]: !wc *
199 In [15]: !wc *
200 2 12 77 README.txt
200 2 12 77 README.txt
201 40 97 884 buttons.py
201 40 97 884 buttons.py
202 26 90 712 check_buttons.py
202 26 90 712 check_buttons.py
203 19 52 416 cursor.py
203 19 52 416 cursor.py
204 180 404 4882 menu.py
204 180 404 4882 menu.py
205 16 45 337 multicursor.py
205 16 45 337 multicursor.py
206 36 106 916 radio_buttons.py
206 36 106 916 radio_buttons.py
207 48 226 2082 rectangle_selector.py
207 48 226 2082 rectangle_selector.py
208 43 118 1063 slider_demo.py
208 43 118 1063 slider_demo.py
209 40 124 1088 span_selector.py
209 40 124 1088 span_selector.py
210 450 1274 12457 total
210 450 1274 12457 total
211
211
212 You can create one or more pyplot plots and insert them with the
212 You can create one or more pyplot plots and insert them with the
213 ``@savefig`` decorator.
213 ``@savefig`` decorator.
214
214
215 .. ipython::
215 .. ipython::
216
216
217 @savefig plot_simple.png width=4in
217 @savefig plot_simple.png width=4in
218 In [151]: plot([1,2,3]);
218 In [151]: plot([1,2,3]);
219
219
220 # use a semicolon to suppress the output
220 # use a semicolon to suppress the output
221 @savefig hist_simple.png width=4in
221 @savefig hist_simple.png width=4in
222 In [151]: hist(np.random.randn(10000), 100);
222 In [151]: hist(np.random.randn(10000), 100);
223
223
224 In a subsequent session, we can update the current figure with some
224 In a subsequent session, we can update the current figure with some
225 text, and then resave
225 text, and then resave
226
226
227 .. ipython::
227 .. ipython::
228
228
229
229
230 In [151]: ylabel('number')
230 In [151]: ylabel('number')
231
231
232 In [152]: title('normal distribution')
232 In [152]: title('normal distribution')
233
233
234 @savefig hist_with_text.png width=4in
234 @savefig hist_with_text.png width=4in
235 In [153]: grid(True)
235 In [153]: grid(True)
236
236
237 You can also have function definitions included in the source.
237 You can also have function definitions included in the source.
238
238
239 .. ipython::
239 .. ipython::
240
240
241 In [3]: def square(x):
241 In [3]: def square(x):
242 ...: """
242 ...: """
243 ...: An overcomplicated square function as an example.
243 ...: An overcomplicated square function as an example.
244 ...: """
244 ...: """
245 ...: if x < 0:
245 ...: if x < 0:
246 ...: x = abs(x)
246 ...: x = abs(x)
247 ...: y = x * x
247 ...: y = x * x
248 ...: return y
248 ...: return y
249 ...:
249 ...:
250
250
251 Then call it from a subsequent section.
251 Then call it from a subsequent section.
252
252
253 .. ipython::
253 .. ipython::
254
254
255 In [4]: square(3)
255 In [4]: square(3)
256 Out [4]: 9
256 Out [4]: 9
257
257
258 In [5]: square(-2)
258 In [5]: square(-2)
259 Out [5]: 4
259 Out [5]: 4
260
260
261
261
262 Writing Pure Python Code
262 Writing Pure Python Code
263 ------------------------
263 ------------------------
264
264
265 Pure python code is supported by the optional argument `python`. In this pure
265 Pure python code is supported by the optional argument `python`. In this pure
266 python syntax you do not include the output from the python interpreter. The
266 python syntax you do not include the output from the python interpreter. The
267 following markup::
267 following markup::
268
268
269 .. ipython:: python
269 .. ipython:: python
270
270
271 foo = 'bar'
271 foo = 'bar'
272 print foo
272 print foo
273 foo = 2
273 foo = 2
274 foo**2
274 foo**2
275
275
276 Renders as
276 Renders as
277
277
278 .. ipython:: python
278 .. ipython:: python
279
279
280 foo = 'bar'
280 foo = 'bar'
281 print foo
281 print foo
282 foo = 2
282 foo = 2
283 foo**2
283 foo**2
284
284
285 We can even plot from python, using the savefig decorator, as well as, suppress
285 We can even plot from python, using the savefig decorator, as well as, suppress
286 output with a semicolon
286 output with a semicolon
287
287
288 .. ipython:: python
288 .. ipython:: python
289
289
290 @savefig plot_simple_python.png width=4in
290 @savefig plot_simple_python.png width=4in
291 plot([1,2,3]);
291 plot([1,2,3]);
292
292
293 Similarly, std err is inserted
293 Similarly, std err is inserted
294
294
295 .. ipython:: python
295 .. ipython:: python
296
296
297 foo = 'bar'
297 foo = 'bar'
298 foo[)
298 foo[)
299
299
300 Comments are handled and state is preserved
300 Comments are handled and state is preserved
301
301
302 .. ipython:: python
302 .. ipython:: python
303
303
304 # comments are handled
304 # comments are handled
305 print foo
305 print foo
306
306
307 If you don't see the next code block then the options work.
307 If you don't see the next code block then the options work.
308
308
309 .. ipython:: python
309 .. ipython:: python
310 :suppress:
310 :suppress:
311
311
312 ioff()
312 ioff()
313 ion()
313 ion()
314
314
315 Multi-line input is handled.
315 Multi-line input is handled.
316
316
317 .. ipython:: python
317 .. ipython:: python
318
318
319 line = 'Multi\
319 line = 'Multi\
320 line &\
320 line &\
321 support &\
321 support &\
322 works'
322 works'
323 print line.split('&')
323 print line.split('&')
324
324
325 Functions definitions are correctly parsed
325 Functions definitions are correctly parsed
326
326
327 .. ipython:: python
327 .. ipython:: python
328
328
329 def square(x):
329 def square(x):
330 """
330 """
331 An overcomplicated square function as an example.
331 An overcomplicated square function as an example.
332 """
332 """
333 if x < 0:
333 if x < 0:
334 x = abs(x)
334 x = abs(x)
335 y = x * x
335 y = x * x
336 return y
336 return y
337
337
338 And persist across sessions
338 And persist across sessions
339
339
340 .. ipython:: python
340 .. ipython:: python
341
341
342 print square(3)
342 print square(3)
343 print square(-2)
343 print square(-2)
344
344
345 Pretty much anything you can do with the ipython code, you can do with
345 Pretty much anything you can do with the ipython code, you can do with
346 with a simple python script. Obviously, though it doesn't make sense
346 with a simple python script. Obviously, though it doesn't make sense
347 to use the doctest option.
347 to use the doctest option.
348
348
349 Pseudo-Decorators
349 Pseudo-Decorators
350 =================
350 =================
351
351
352 Here are the supported decorators, and any optional arguments they
352 Here are the supported decorators, and any optional arguments they
353 take. Some of the decorators can be used as options to the entire
353 take. Some of the decorators can be used as options to the entire
354 block (eg ``verbatim`` and ``suppress``), and some only apply to the
354 block (eg ``verbatim`` and ``suppress``), and some only apply to the
355 line just below them (eg ``savefig``).
355 line just below them (eg ``savefig``).
356
356
357 @suppress
357 @suppress
358
358
359 execute the ipython input block, but suppress the input and output
359 execute the ipython input block, but suppress the input and output
360 block from the rendered output. Also, can be applied to the entire
360 block from the rendered output. Also, can be applied to the entire
361 ``..ipython`` block as a directive option with ``:suppress:``.
361 ``..ipython`` block as a directive option with ``:suppress:``.
362
362
363 @verbatim
363 @verbatim
364
364
365 insert the input and output block in verbatim, but auto-increment
365 insert the input and output block in verbatim, but auto-increment
366 the line numbers. Internally, the interpreter will be fed an empty
366 the line numbers. Internally, the interpreter will be fed an empty
367 string, so it is a no-op that keeps line numbering consistent.
367 string, so it is a no-op that keeps line numbering consistent.
368 Also, can be applied to the entire ``..ipython`` block as a
368 Also, can be applied to the entire ``..ipython`` block as a
369 directive option with ``:verbatim:``.
369 directive option with ``:verbatim:``.
370
370
371 @savefig OUTFILE [IMAGE_OPTIONS]
371 @savefig OUTFILE [IMAGE_OPTIONS]
372
372
373 save the figure to the static directory and insert it into the
373 save the figure to the static directory and insert it into the
374 document, possibly binding it into a minipage and/or putting
374 document, possibly binding it into a minipage and/or putting
375 code/figure label/references to associate the code and the
375 code/figure label/references to associate the code and the
376 figure. Takes args to pass to the image directive (*scale*,
376 figure. Takes args to pass to the image directive (*scale*,
377 *width*, etc can be kwargs); see `image options
377 *width*, etc can be kwargs); see `image options
378 <http://docutils.sourceforge.net/docs/ref/rst/directives.html#image>`_
378 <http://docutils.sourceforge.net/docs/ref/rst/directives.html#image>`_
379 for details.
379 for details.
380
380
381 @doctest
381 @doctest
382
382
383 Compare the pasted in output in the ipython block with the output
383 Compare the pasted in output in the ipython block with the output
384 generated at doc build time, and raise errors if they donÒ€ℒt
384 generated at doc build time, and raise errors if they donÒ€ℒt
385 match. Also, can be applied to the entire ``..ipython`` block as a
385 match. Also, can be applied to the entire ``..ipython`` block as a
386 directive option with ``:doctest:``.
386 directive option with ``:doctest:``.
387
387
388 Configuration Options
388 Configuration Options
389 =====================
389 =====================
390
390
391 ipython_savefig_dir
391 ipython_savefig_dir
392
392
393 The directory in which to save the figures. This is relative to the
393 The directory in which to save the figures. This is relative to the
394 Sphinx source directory. The default is `html_static_path`.
394 Sphinx source directory. The default is `html_static_path`.
395
395
396 ipython_rgxin
396 ipython_rgxin
397
397
398 The compiled regular expression to denote the start of IPython input
398 The compiled regular expression to denote the start of IPython input
399 lines. The default is re.compile('In \[(\d+)\]:\s?(.*)\s*'). You
399 lines. The default is re.compile('In \[(\d+)\]:\s?(.*)\s*'). You
400 shouldn't need to change this.
400 shouldn't need to change this.
401
401
402 ipython_rgxout
402 ipython_rgxout
403
403
404 The compiled regular expression to denote the start of IPython output
404 The compiled regular expression to denote the start of IPython output
405 lines. The default is re.compile('Out\[(\d+)\]:\s?(.*)\s*'). You
405 lines. The default is re.compile('Out\[(\d+)\]:\s?(.*)\s*'). You
406 shouldn't need to change this.
406 shouldn't need to change this.
407
407
408
408
409 ipython_promptin
409 ipython_promptin
410
410
411 The string to represent the IPython input prompt in the generated ReST.
411 The string to represent the IPython input prompt in the generated ReST.
412 The default is 'In [%d]:'. This expects that the line numbers are used
412 The default is 'In [%d]:'. This expects that the line numbers are used
413 in the prompt.
413 in the prompt.
414
414
415 ipython_promptout
415 ipython_promptout
416
416
417 The string to represent the IPython prompt in the generated ReST. The
417 The string to represent the IPython prompt in the generated ReST. The
418 default is 'Out [%d]:'. This expects that the line numbers are used
418 default is 'Out [%d]:'. This expects that the line numbers are used
419 in the prompt.
419 in the prompt.
@@ -1,32 +1,38 b''
1 =====================
1 =====================
2 IPython Documentation
2 IPython Documentation
3 =====================
3 =====================
4
4
5 .. htmlonly::
5 .. htmlonly::
6
6
7 :Release: |release|
7 :Release: |release|
8 :Date: |today|
8 :Date: |today|
9
9
10 Welcome to the official IPython documentation.
10 .. only:: not rtd
11
12 Welcome to the official IPython documentation.
13
14 .. only:: rtd
15
16 This is a partial copy of IPython documentation, please visit `IPython official documentation <http://ipython.org/documentation.html>`_.
11
17
12 Contents
18 Contents
13 ========
19 ========
14
20
15 .. toctree::
21 .. toctree::
16 :maxdepth: 1
22 :maxdepth: 1
17
23
18 overview.txt
24 overview.txt
19 whatsnew/index.txt
25 whatsnew/index.txt
20 install/index.txt
26 install/index.txt
21 interactive/index.txt
27 interactive/index.txt
22 parallel/index.txt
28 parallel/index.txt
23 config/index.txt
29 config/index.txt
24 development/index.txt
30 development/index.txt
25 api/index.txt
31 api/index.txt
26 about/index.txt
32 about/index.txt
27
33
28 .. htmlonly::
34 .. htmlonly::
29 * :ref:`genindex`
35 * :ref:`genindex`
30 * :ref:`modindex`
36 * :ref:`modindex`
31 * :ref:`search`
37 * :ref:`search`
32
38
General Comments 0
You need to be logged in to leave comments. Login now