Show More
@@ -2,6 +2,11 b'' | |||||
2 | """ |
|
2 | """ | |
3 | A base class for objects that are configurable. |
|
3 | A base class for objects that are configurable. | |
4 |
|
4 | |||
|
5 | Inheritance diagram: | |||
|
6 | ||||
|
7 | .. inheritance-diagram:: IPython.config.configurable | |||
|
8 | :parts: 3 | |||
|
9 | ||||
5 | Authors: |
|
10 | Authors: | |
6 |
|
11 | |||
7 | * Brian Granger |
|
12 | * Brian Granger |
@@ -1,5 +1,10 b'' | |||||
1 | """A simple configuration system. |
|
1 | """A simple configuration system. | |
2 |
|
2 | |||
|
3 | Inheritance diagram: | |||
|
4 | ||||
|
5 | .. inheritance-diagram:: IPython.config.loader | |||
|
6 | :parts: 3 | |||
|
7 | ||||
3 | Authors |
|
8 | Authors | |
4 | ------- |
|
9 | ------- | |
5 | * Brian Granger |
|
10 | * Brian Granger |
@@ -1,6 +1,10 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """Display formatters. |
|
2 | """Display formatters. | |
3 |
|
3 | |||
|
4 | Inheritance diagram: | |||
|
5 | ||||
|
6 | .. inheritance-diagram:: IPython.core.formatters | |||
|
7 | :parts: 3 | |||
4 |
|
8 | |||
5 | Authors: |
|
9 | Authors: | |
6 |
|
10 |
@@ -37,6 +37,11 b' arguments::' | |||||
37 | -o OPTION, --option OPTION |
|
37 | -o OPTION, --option OPTION | |
38 | An optional argument. |
|
38 | An optional argument. | |
39 |
|
39 | |||
|
40 | Inheritance diagram: | |||
|
41 | ||||
|
42 | .. inheritance-diagram:: IPython.core.magic_arguments | |||
|
43 | :parts: 3 | |||
|
44 | ||||
40 | ''' |
|
45 | ''' | |
41 | #----------------------------------------------------------------------------- |
|
46 | #----------------------------------------------------------------------------- | |
42 | # Copyright (C) 2010-2011, IPython Development Team. |
|
47 | # Copyright (C) 2010-2011, IPython Development Team. |
@@ -59,6 +59,11 b' ColorSchemeTable class. Currently the following exist:' | |||||
59 | You can implement other color schemes easily, the syntax is fairly |
|
59 | You can implement other color schemes easily, the syntax is fairly | |
60 | self-explanatory. Please send back new schemes you develop to the author for |
|
60 | self-explanatory. Please send back new schemes you develop to the author for | |
61 | possible inclusion in future releases. |
|
61 | possible inclusion in future releases. | |
|
62 | ||||
|
63 | Inheritance diagram: | |||
|
64 | ||||
|
65 | .. inheritance-diagram:: IPython.core.ultratb | |||
|
66 | :parts: 3 | |||
62 | """ |
|
67 | """ | |
63 |
|
68 | |||
64 | #***************************************************************************** |
|
69 | #***************************************************************************** |
@@ -1,6 +1,3 b'' | |||||
1 | from __future__ import unicode_literals |
|
|||
2 |
|
||||
3 |
|
||||
4 |
|
|
1 | """Module for interactive demos using IPython. | |
5 |
|
2 | |||
6 | This module implements a few classes for running Python scripts interactively |
|
3 | This module implements a few classes for running Python scripts interactively | |
@@ -10,7 +7,7 b' control to IPython.' | |||||
10 |
|
7 | |||
11 |
|
8 | |||
12 | Provided classes |
|
9 | Provided classes | |
13 | ================ |
|
10 | ---------------- | |
14 |
|
11 | |||
15 | The classes are (see their docstrings for further details): |
|
12 | The classes are (see their docstrings for further details): | |
16 |
|
13 | |||
@@ -33,9 +30,13 b' The classes are (see their docstrings for further details):' | |||||
33 | - ClearDemo, ClearIPDemo: mixin-enabled versions of the Demo and IPythonDemo |
|
30 | - ClearDemo, ClearIPDemo: mixin-enabled versions of the Demo and IPythonDemo | |
34 | classes. |
|
31 | classes. | |
35 |
|
32 | |||
|
33 | Inheritance diagram: | |||
|
34 | ||||
|
35 | .. inheritance-diagram:: IPython.lib.demo | |||
|
36 | :parts: 3 | |||
36 |
|
37 | |||
37 | Subclassing |
|
38 | Subclassing | |
38 | =========== |
|
39 | ----------- | |
39 |
|
40 | |||
40 | The classes here all include a few methods meant to make customization by |
|
41 | The classes here all include a few methods meant to make customization by | |
41 | subclassing more convenient. Their docstrings below have some more details: |
|
42 | subclassing more convenient. Their docstrings below have some more details: | |
@@ -50,7 +51,7 b' subclassing more convenient. Their docstrings below have some more details:' | |||||
50 |
|
51 | |||
51 |
|
52 | |||
52 | Operation |
|
53 | Operation | |
53 | ========= |
|
54 | --------- | |
54 |
|
55 | |||
55 | The file is run in its own empty namespace (though you can pass it a string of |
|
56 | The file is run in its own empty namespace (though you can pass it a string of | |
56 | arguments as if in a command line environment, and it will see those as |
|
57 | arguments as if in a command line environment, and it will see those as | |
@@ -123,47 +124,51 b' an IPython session, and type::' | |||||
123 | and then follow the directions. |
|
124 | and then follow the directions. | |
124 |
|
125 | |||
125 | Example |
|
126 | Example | |
126 | ======= |
|
127 | ------- | |
127 |
|
128 | |||
128 | The following is a very simple example of a valid demo file. |
|
129 | The following is a very simple example of a valid demo file. | |
129 |
|
130 | |||
130 | #################### EXAMPLE DEMO <ex_demo.py> ############################### |
|
131 | :: | |
131 | '''A simple interactive demo to illustrate the use of IPython's Demo class.''' |
|
|||
132 |
|
132 | |||
133 | print 'Hello, welcome to an interactive IPython demo.' |
|
133 | #################### EXAMPLE DEMO <ex_demo.py> ############################### | |
|
134 | '''A simple interactive demo to illustrate the use of IPython's Demo class.''' | |||
134 |
|
135 | |||
135 | # The mark below defines a block boundary, which is a point where IPython will |
|
136 | print 'Hello, welcome to an interactive IPython demo.' | |
136 | # stop execution and return to the interactive prompt. The dashes are actually |
|
|||
137 | # optional and used only as a visual aid to clearly separate blocks while |
|
|||
138 | # editing the demo code. |
|
|||
139 | # <demo> stop |
|
|||
140 |
|
137 | |||
141 | x = 1 |
|
138 | # The mark below defines a block boundary, which is a point where IPython will | |
142 | y = 2 |
|
139 | # stop execution and return to the interactive prompt. The dashes are actually | |
|
140 | # optional and used only as a visual aid to clearly separate blocks while | |||
|
141 | # editing the demo code. | |||
|
142 | # <demo> stop | |||
143 |
|
143 | |||
144 | # <demo> stop |
|
144 | x = 1 | |
|
145 | y = 2 | |||
145 |
|
146 | |||
146 | # the mark below makes this block as silent |
|
147 | # <demo> stop | |
147 | # <demo> silent |
|
|||
148 |
|
148 | |||
149 | print 'This is a silent block, which gets executed but not printed.' |
|
149 | # the mark below makes this block as silent | |
|
150 | # <demo> silent | |||
150 |
|
151 | |||
151 | # <demo> stop |
|
152 | print 'This is a silent block, which gets executed but not printed.' | |
152 | # <demo> auto |
|
|||
153 | print 'This is an automatic block.' |
|
|||
154 | print 'It is executed without asking for confirmation, but printed.' |
|
|||
155 | z = x+y |
|
|||
156 |
|
153 | |||
157 | print 'z=',x |
|
154 | # <demo> stop | |
|
155 | # <demo> auto | |||
|
156 | print 'This is an automatic block.' | |||
|
157 | print 'It is executed without asking for confirmation, but printed.' | |||
|
158 | z = x+y | |||
158 |
|
159 | |||
159 | # <demo> stop |
|
160 | print 'z=',x | |
160 | # This is just another normal block. |
|
|||
161 | print 'z is now:', z |
|
|||
162 |
|
161 | |||
163 | print 'bye!' |
|
162 | # <demo> stop | |
164 | ################### END EXAMPLE DEMO <ex_demo.py> ############################ |
|
163 | # This is just another normal block. | |
|
164 | print 'z is now:', z | |||
|
165 | ||||
|
166 | print 'bye!' | |||
|
167 | ################### END EXAMPLE DEMO <ex_demo.py> ############################ | |||
165 | """ |
|
168 | """ | |
166 |
|
169 | |||
|
170 | from __future__ import unicode_literals | |||
|
171 | ||||
167 | #***************************************************************************** |
|
172 | #***************************************************************************** | |
168 | # Copyright (C) 2005-2006 Fernando Perez. <Fernando.Perez@colorado.edu> |
|
173 | # Copyright (C) 2005-2006 Fernando Perez. <Fernando.Perez@colorado.edu> | |
169 | # |
|
174 | # |
@@ -18,16 +18,14 b' contributed on the ipython-user list:' | |||||
18 |
|
18 | |||
19 | http://mail.scipy.org/pipermail/ipython-user/2006-May/003539.html |
|
19 | http://mail.scipy.org/pipermail/ipython-user/2006-May/003539.html | |
20 |
|
20 | |||
21 |
|
21 | Notes | ||
22 | NOTES: |
|
22 | ----- | |
23 |
|
23 | |||
24 | - This module requires pexpect, available in most linux distros, or which can |
|
24 | - This module requires pexpect, available in most linux distros, or which can | |
25 | be downloaded from |
|
25 | be downloaded from http://pexpect.sourceforge.net | |
26 |
|
||||
27 | http://pexpect.sourceforge.net |
|
|||
28 |
|
26 | |||
29 | - Because pexpect only works under Unix or Windows-Cygwin, this has the same |
|
27 | - Because pexpect only works under Unix or Windows-Cygwin, this has the same | |
30 | limitations. This means that it will NOT work under native windows Python. |
|
28 | limitations. This means that it will NOT work under native windows Python. | |
31 | """ |
|
29 | """ | |
32 | from __future__ import print_function |
|
30 | from __future__ import print_function | |
33 |
|
31 |
@@ -1,105 +1,107 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """ |
|
2 | """ | |
3 | pretty |
|
3 | Python advanced pretty printer. This pretty printer is intended to | |
4 | ~~ |
|
4 | replace the old `pprint` python module which does not allow developers | |
|
5 | to provide their own pretty print callbacks. | |||
5 |
|
6 | |||
6 | Python advanced pretty printer. This pretty printer is intended to |
|
7 | This module is based on ruby's `prettyprint.rb` library by `Tanaka Akira`. | |
7 | replace the old `pprint` python module which does not allow developers |
|
|||
8 | to provide their own pretty print callbacks. |
|
|||
9 |
|
8 | |||
10 | This module is based on ruby's `prettyprint.rb` library by `Tanaka Akira`. |
|
|||
11 |
|
9 | |||
|
10 | Example Usage | |||
|
11 | ------------- | |||
12 |
|
12 | |||
13 | Example Usage |
|
13 | To directly print the representation of an object use `pprint`:: | |
14 | ============= |
|
|||
15 |
|
14 | |||
16 | To directly print the representation of an object use `pprint`:: |
|
15 | from pretty import pprint | |
|
16 | pprint(complex_object) | |||
17 |
|
17 | |||
18 | from pretty import pprint |
|
18 | To get a string of the output use `pretty`:: | |
19 | pprint(complex_object) |
|
|||
20 |
|
19 | |||
21 | To get a string of the output use `pretty`:: |
|
20 | from pretty import pretty | |
|
21 | string = pretty(complex_object) | |||
22 |
|
22 | |||
23 | from pretty import pretty |
|
|||
24 | string = pretty(complex_object) |
|
|||
25 |
|
23 | |||
|
24 | Extending | |||
|
25 | --------- | |||
26 |
|
26 | |||
27 | Extending |
|
27 | The pretty library allows developers to add pretty printing rules for their | |
28 | ========= |
|
28 | own objects. This process is straightforward. All you have to do is to | |
|
29 | add a `_repr_pretty_` method to your object and call the methods on the | |||
|
30 | pretty printer passed:: | |||
29 |
|
31 | |||
30 | The pretty library allows developers to add pretty printing rules for their |
|
32 | class MyObject(object): | |
31 | own objects. This process is straightforward. All you have to do is to |
|
|||
32 | add a `_repr_pretty_` method to your object and call the methods on the |
|
|||
33 | pretty printer passed:: |
|
|||
34 |
|
33 | |||
35 | class MyObject(object): |
|
34 | def _repr_pretty_(self, p, cycle): | |
36 |
|
35 | ... | ||
37 | def _repr_pretty_(self, p, cycle): |
|
|||
38 | ... |
|
|||
39 |
|
36 | |||
40 |
|
|
37 | Depending on the python version you want to support you have two | |
41 |
|
|
38 | possibilities. The following list shows the python 2.5 version and the | |
42 |
|
|
39 | compatibility one. | |
43 |
|
40 | |||
44 |
|
41 | |||
45 |
|
|
42 | Here the example implementation of a `_repr_pretty_` method for a list | |
46 |
|
|
43 | subclass for python 2.5 and higher (python 2.5 requires the with statement | |
47 |
|
|
44 | __future__ import):: | |
48 |
|
45 | |||
49 |
|
|
46 | class MyList(list): | |
50 |
|
47 | |||
51 |
|
|
48 | def _repr_pretty_(self, p, cycle): | |
52 |
|
|
49 | if cycle: | |
53 |
|
|
50 | p.text('MyList(...)') | |
54 |
|
|
51 | else: | |
55 |
|
|
52 | with p.group(8, 'MyList([', '])'): | |
56 | for idx, item in enumerate(self): |
|
|||
57 | if idx: |
|
|||
58 | p.text(',') |
|
|||
59 | p.breakable() |
|
|||
60 | p.pretty(item) |
|
|||
61 |
|
||||
62 | The `cycle` parameter is `True` if pretty detected a cycle. You *have* to |
|
|||
63 | react to that or the result is an infinite loop. `p.text()` just adds |
|
|||
64 | non breaking text to the output, `p.breakable()` either adds a whitespace |
|
|||
65 | or breaks here. If you pass it an argument it's used instead of the |
|
|||
66 | default space. `p.pretty` prettyprints another object using the pretty print |
|
|||
67 | method. |
|
|||
68 |
|
||||
69 | The first parameter to the `group` function specifies the extra indentation |
|
|||
70 | of the next line. In this example the next item will either be not |
|
|||
71 | breaked (if the items are short enough) or aligned with the right edge of |
|
|||
72 | the opening bracked of `MyList`. |
|
|||
73 |
|
||||
74 | If you want to support python 2.4 and lower you can use this code:: |
|
|||
75 |
|
||||
76 | class MyList(list): |
|
|||
77 |
|
||||
78 | def _repr_pretty_(self, p, cycle): |
|
|||
79 | if cycle: |
|
|||
80 | p.text('MyList(...)') |
|
|||
81 | else: |
|
|||
82 | p.begin_group(8, 'MyList([') |
|
|||
83 | for idx, item in enumerate(self): |
|
53 | for idx, item in enumerate(self): | |
84 | if idx: |
|
54 | if idx: | |
85 | p.text(',') |
|
55 | p.text(',') | |
86 | p.breakable() |
|
56 | p.breakable() | |
87 | p.pretty(item) |
|
57 | p.pretty(item) | |
88 | p.end_group(8, '])') |
|
|||
89 |
|
58 | |||
90 | If you just want to indent something you can use the group function |
|
59 | The `cycle` parameter is `True` if pretty detected a cycle. You *have* to | |
91 | without open / close parameters. Under python 2.5 you can also use this |
|
60 | react to that or the result is an infinite loop. `p.text()` just adds | |
92 | code:: |
|
61 | non breaking text to the output, `p.breakable()` either adds a whitespace | |
|
62 | or breaks here. If you pass it an argument it's used instead of the | |||
|
63 | default space. `p.pretty` prettyprints another object using the pretty print | |||
|
64 | method. | |||
93 |
|
65 | |||
94 | with p.indent(2): |
|
66 | The first parameter to the `group` function specifies the extra indentation | |
95 | ... |
|
67 | of the next line. In this example the next item will either be not | |
|
68 | breaked (if the items are short enough) or aligned with the right edge of | |||
|
69 | the opening bracked of `MyList`. | |||
|
70 | ||||
|
71 | If you want to support python 2.4 and lower you can use this code:: | |||
|
72 | ||||
|
73 | class MyList(list): | |||
|
74 | ||||
|
75 | def _repr_pretty_(self, p, cycle): | |||
|
76 | if cycle: | |||
|
77 | p.text('MyList(...)') | |||
|
78 | else: | |||
|
79 | p.begin_group(8, 'MyList([') | |||
|
80 | for idx, item in enumerate(self): | |||
|
81 | if idx: | |||
|
82 | p.text(',') | |||
|
83 | p.breakable() | |||
|
84 | p.pretty(item) | |||
|
85 | p.end_group(8, '])') | |||
|
86 | ||||
|
87 | If you just want to indent something you can use the group function | |||
|
88 | without open / close parameters. Under python 2.5 you can also use this | |||
|
89 | code:: | |||
|
90 | ||||
|
91 | with p.indent(2): | |||
|
92 | ... | |||
|
93 | ||||
|
94 | Or under python2.4 you might want to modify ``p.indentation`` by hand but | |||
|
95 | this is rather ugly. | |||
|
96 | ||||
|
97 | Inheritance diagram: | |||
96 |
|
98 | |||
97 | Or under python2.4 you might want to modify ``p.indentation`` by hand but |
|
99 | .. inheritance-diagram:: IPython.lib.pretty | |
98 | this is rather ugly. |
|
100 | :parts: 3 | |
99 |
|
101 | |||
100 |
|
|
102 | :copyright: 2007 by Armin Ronacher. | |
101 |
|
|
103 | Portions (c) 2009 by Robert Kern. | |
102 |
|
|
104 | :license: BSD License. | |
103 | """ |
|
105 | """ | |
104 | from __future__ import with_statement |
|
106 | from __future__ import with_statement | |
105 | from contextlib import contextmanager |
|
107 | from contextlib import contextmanager |
@@ -2,6 +2,11 b'' | |||||
2 |
|
2 | |||
3 | """Classes and functions for kernel related errors and exceptions. |
|
3 | """Classes and functions for kernel related errors and exceptions. | |
4 |
|
4 | |||
|
5 | Inheritance diagram: | |||
|
6 | ||||
|
7 | .. inheritance-diagram:: IPython.parallel.error | |||
|
8 | :parts: 3 | |||
|
9 | ||||
5 | Authors: |
|
10 | Authors: | |
6 |
|
11 | |||
7 | * Brian Granger |
|
12 | * Brian Granger |
@@ -1,6 +1,11 b'' | |||||
1 | # encoding: utf-8 |
|
1 | # encoding: utf-8 | |
2 | """ |
|
2 | """ | |
3 | Utilities for working with strings and text. |
|
3 | Utilities for working with strings and text. | |
|
4 | ||||
|
5 | Inheritance diagram: | |||
|
6 | ||||
|
7 | .. inheritance-diagram:: IPython.utils.text | |||
|
8 | :parts: 3 | |||
4 | """ |
|
9 | """ | |
5 |
|
10 | |||
6 | #----------------------------------------------------------------------------- |
|
11 | #----------------------------------------------------------------------------- |
@@ -28,6 +28,11 b' We choose to create this module because we need these capabilities, but' | |||||
28 | we need them to be pure Python so they work in all Python implementations, |
|
28 | we need them to be pure Python so they work in all Python implementations, | |
29 | including Jython and IronPython. |
|
29 | including Jython and IronPython. | |
30 |
|
30 | |||
|
31 | Inheritance diagram: | |||
|
32 | ||||
|
33 | .. inheritance-diagram:: IPython.utils.traitlets | |||
|
34 | :parts: 3 | |||
|
35 | ||||
31 | Authors: |
|
36 | Authors: | |
32 |
|
37 | |||
33 | * Brian Granger |
|
38 | * Brian Granger |
@@ -219,11 +219,6 b' class ApiDocWriter(object):' | |||||
219 | chap_title = ':mod:`' + uri_short + '`' |
|
219 | chap_title = ':mod:`' + uri_short + '`' | |
220 | ad += chap_title + '\n' + self.rst_section_levels[1] * len(chap_title) |
|
220 | ad += chap_title + '\n' + self.rst_section_levels[1] * len(chap_title) | |
221 |
|
221 | |||
222 | if len(classes): |
|
|||
223 | ad += '\nInheritance diagram for ``%s``:\n\n' % uri |
|
|||
224 | ad += '.. inheritance-diagram:: %s \n' % uri |
|
|||
225 | ad += ' :parts: 3\n' |
|
|||
226 |
|
||||
227 | ad += '\n.. automodule:: ' + uri + '\n' |
|
222 | ad += '\n.. automodule:: ' + uri + '\n' | |
228 | ad += '\n.. currentmodule:: ' + uri + '\n' |
|
223 | ad += '\n.. currentmodule:: ' + uri + '\n' | |
229 | multi_class = len(classes) > 1 |
|
224 | multi_class = len(classes) > 1 |
General Comments 0
You need to be logged in to leave comments.
Login now