##// END OF EJS Templates
ipy_leo: improved ipy_leo docs
Ville M. Vainio -
Show More
@@ -3,16 +3,19 b''
3 <leo_file>
3 <leo_file>
4 <leo_header file_format="2" tnodes="0" max_tnode_index="0" clone_windows="0"/>
4 <leo_header file_format="2" tnodes="0" max_tnode_index="0" clone_windows="0"/>
5 <globals body_outline_ratio="0.5">
5 <globals body_outline_ratio="0.5">
6 <global_window_position top="165" left="26" height="621" width="1280"/>
6 <global_window_position top="261" left="404" height="621" width="1280"/>
7 <global_log_window_position top="0" left="0" height="0" width="0"/>
7 <global_log_window_position top="0" left="0" height="0" width="0"/>
8 </globals>
8 </globals>
9 <preferences/>
9 <preferences/>
10 <find_panel_settings/>
10 <find_panel_settings/>
11 <vnodes>
11 <vnodes>
12 <v t="vivainio.20080218184525"><vh>@chapters</vh></v>
12 <v t="vivainio.20080218184525"><vh>@chapters</vh></v>
13 <v t="vivainio.20080223133721" a="E"><vh>@settings</vh>
14 <v t="vivainio.20080223133721.1"><vh>@enabled-plugins</vh></v>
15 </v>
13 <v t="vivainio.20080218184540" a="E"><vh>@ipy-startup</vh>
16 <v t="vivainio.20080218184540" a="E"><vh>@ipy-startup</vh>
14 <v t="vivainio.20080218184613.1"><vh>b</vh></v>
17 <v t="vivainio.20080218184613.1"><vh>b</vh></v>
15 <v t="vivainio.20080218200031"><vh>Some classes P</vh>
18 <v t="vivainio.20080218200031" a="E"><vh>Some classes P</vh>
16 <v t="vivainio.20080218190816"><vh>File-like access</vh></v>
19 <v t="vivainio.20080218190816"><vh>File-like access</vh></v>
17 <v t="vivainio.20080218200106"><vh>csv data</vh></v>
20 <v t="vivainio.20080218200106"><vh>csv data</vh></v>
18 <v t="vivainio.20080219225120"><vh>String list</vh></v>
21 <v t="vivainio.20080219225120"><vh>String list</vh></v>
@@ -30,7 +33,18 b''
30 <v t="vivainio.20080218201219.2"><vh>bar</vh></v>
33 <v t="vivainio.20080218201219.2"><vh>bar</vh></v>
31 </v>
34 </v>
32 <v t="vivainio.20080222193236" a="E"><vh>Docs</vh>
35 <v t="vivainio.20080222193236" a="E"><vh>Docs</vh>
33 <v t="vivainio.20080222193236.1" a="TV"><vh>Quick intro</vh></v>
36 <v t="vivainio.20080223121915" a="E" tnodeList="vivainio.20080223121915,vivainio.20080222193236.1,vivainio.20080223133858,vivainio.20080223133922,vivainio.20080223133947,vivainio.20080223134018,vivainio.20080223134100,vivainio.20080223134118,vivainio.20080223134433,vivainio.20080223134136"><vh>@nosent ileointro.txt</vh>
37 <v t="vivainio.20080222193236.1" a="E"><vh>Quick intro</vh>
38 <v t="vivainio.20080223133858"><vh>Introduction</vh></v>
39 <v t="vivainio.20080223133922"><vh>Installation</vh></v>
40 <v t="vivainio.20080223133947"><vh>Accessing IPython from Leo</vh></v>
41 <v t="vivainio.20080223134018"><vh>Accessing Leo nodes from IPython</vh></v>
42 <v t="vivainio.20080223134100"><vh>Cl definitions</vh></v>
43 <v t="vivainio.20080223134118"><vh>Special node types</vh></v>
44 <v t="vivainio.20080223134433" a="TV"><vh>Custom push</vh></v>
45 <v t="vivainio.20080223134136"><vh>Acknowledgements and history</vh></v>
46 </v>
47 </v>
34 </v>
48 </v>
35 <v t="vivainio.20080222202211"><vh>test stuff</vh></v>
49 <v t="vivainio.20080222202211"><vh>test stuff</vh></v>
36 <v t="vivainio.20080222202211.1"><vh>spam</vh></v>
50 <v t="vivainio.20080222202211.1"><vh>spam</vh></v>
@@ -104,8 +118,26 b' def format_slist(obj):'
104 </t>
118 </t>
105 <t tx="vivainio.20080222193236"></t>
119 <t tx="vivainio.20080222193236"></t>
106 <t tx="vivainio.20080222193236.1">@wrap
120 <t tx="vivainio.20080222193236.1">@wrap
107 @nocolor
121 @nocolor</t>
122 <t tx="vivainio.20080222201226">1+2
123 print "hello"
124 3+4
108
125
126 def f(x):
127 return x.upper()
128
129 f('hello world')</t>
130 <t tx="vivainio.20080222202211"></t>
131 <t tx="vivainio.20080222202211.1">@cl rfile
132 hello
133 world
134 and whatever</t>
135 <t tx="vivainio.20080222202211.2"></t>
136 <t tx="vivainio.20080223121915">@others
137 </t>
138 <t tx="vivainio.20080223133721"></t>
139 <t tx="vivainio.20080223133721.1">ipython.py</t>
140 <t tx="vivainio.20080223133858">
109 Introduction
141 Introduction
110 ============
142 ============
111
143
@@ -126,13 +158,13 b' Obviously, you can save the Leo document as usual - this is a great advantage'
126 of ILeo over using %edit, you can save your experimental scripts all at one
158 of ILeo over using %edit, you can save your experimental scripts all at one
127 time, without having to organize them into script/module files (before you
159 time, without having to organize them into script/module files (before you
128 really want to, of course!)
160 really want to, of course!)
129
161 </t>
130
162 <t tx="vivainio.20080223133922">
131 Installation
163 Installation
132 ============
164 ============
133
165
134 You need the latest version of Leo, and the development version of IPython (ILeo
166 You need at least Leo 4.4.7, and the development version of IPython (ILeo
135 will be incorporated to IPython 0.8.3.
167 will be incorporated to IPython 0.8.3).
136
168
137 You can get IPython from Launchpad by installing bzr and doing
169 You can get IPython from Launchpad by installing bzr and doing
138
170
@@ -150,8 +182,9 b" You need to enable the 'ipython.py' plugin in Leo:"
150
182
151 - Press alt+5 OR alt-x start-ipython to launch IPython in the console that
183 - Press alt+5 OR alt-x start-ipython to launch IPython in the console that
152 started leo. You can start entering IPython commands normally, and Leo will keep
184 started leo. You can start entering IPython commands normally, and Leo will keep
153 running in the same time.
185 running at the same time.
154
186 </t>
187 <t tx="vivainio.20080223133947">
155 Accessing IPython from Leo
188 Accessing IPython from Leo
156 ==========================
189 ==========================
157
190
@@ -181,7 +214,7 b" f('hello world')"
181 }}}
214 }}}
182
215
183 If you press alt+I on that done, you will see the following in Leo log window (IPython tab):
216 If you press alt+I on that done, you will see the following in Leo log window (IPython tab):
184
217
185 {{{
218 {{{
186 In: 1+2
219 In: 1+2
187 &lt;2&gt; 3
220 &lt;2&gt; 3
@@ -203,7 +236,8 b" through IPython translation mechanism but use the direct python 'exec' statement"
203 history, and sometimes it is safer (and more efficient) to execute things as
236 history, and sometimes it is safer (and more efficient) to execute things as
204 plain Python statements. Large class definitions are good candidates for P
237 plain Python statements. Large class definitions are good candidates for P
205 nodes.
238 nodes.
206
239 </t>
240 <t tx="vivainio.20080223134018">
207 Accessing Leo nodes from IPython
241 Accessing Leo nodes from IPython
208 ================================
242 ================================
209
243
@@ -229,7 +263,7 b" Suppose that we had a node with headline 'spam' and body:"
229 ['12',2222+32]
263 ['12',2222+32]
230
264
231 we can access it from IPython (or from scripts entered into other Leo nodes!) by doing:
265 we can access it from IPython (or from scripts entered into other Leo nodes!) by doing:
232
266
233 C:leo/src]|19&gt; wb.spam.v
267 C:leo/src]|19&gt; wb.spam.v
234 &lt;19&gt; ['12', 2254]
268 &lt;19&gt; ['12', 2254]
235
269
@@ -256,7 +290,8 b" contents as string list (IPython SList) through 'wb.spam.l'."
256
290
257 If you do 'wb.foo.v = 12' when node named 'foo' does not exist, the node titled
291 If you do 'wb.foo.v = 12' when node named 'foo' does not exist, the node titled
258 'foo' will be automatically created and assigned body 12.
292 'foo' will be automatically created and assigned body 12.
259
293 </t>
294 <t tx="vivainio.20080223134100">
260 @cl definitions
295 @cl definitions
261 ===============
296 ===============
262
297
@@ -301,7 +336,8 b' Now, on IPython, we can do this:'
301 }}}
336 }}}
302
337
303 You should declare new @cl types to make ILeo as convenient your problem domain as possible. For example, a "@cl etree" could return the elementtree object for xml content, or
338 You should declare new @cl types to make ILeo as convenient your problem domain as possible. For example, a "@cl etree" could return the elementtree object for xml content, or
304
339 </t>
340 <t tx="vivainio.20080223134118">
305 Special node types
341 Special node types
306 ==================
342 ==================
307
343
@@ -325,15 +361,16 b' You can attach these as children of existing nodes to provide a way to access'
325 nodes with arbitrary headlines, or to provide aliases to other nodes. If
361 nodes with arbitrary headlines, or to provide aliases to other nodes. If
326 multiple @a nodes are attached as children of a node, all the names can be used
362 multiple @a nodes are attached as children of a node, all the names can be used
327 to access the same object.
363 to access the same object.
328
364 </t>
365 <t tx="vivainio.20080223134136">
329 Acknowledgements &amp; History
366 Acknowledgements &amp; History
330 ==========================
367 ==========================
331
368
332 This idea got started when I (Ville) saw this post by Edward Ream (the author of
369 This idea got started when I (Ville) saw this post by Edward Ream (the author of
333 Leo) on IPython developer mailing list:
370 Leo) on IPython developer mailing list:
334
371
335 http://lists.ipython.scipy.org/pipermail/ipython-dev/2008-January/003551.html
372 http://lists.ipython.scipy.org/pipermail/ipython-dev/2008-January/003551.html
336
373
337 I was using FreeMind as mind mapping software, and so I had an immediate use
374 I was using FreeMind as mind mapping software, and so I had an immediate use
338 case for Leo (which, incidentally, is superior to FreeMind as mind mapper). The
375 case for Leo (which, incidentally, is superior to FreeMind as mind mapper). The
339 wheels started rolling, I got obsessed with the power of this concept
376 wheels started rolling, I got obsessed with the power of this concept
@@ -344,20 +381,29 b' revolutionary technologies (think Python here).'
344 The discussion that "built" ILeo is here:
381 The discussion that "built" ILeo is here:
345 http://sourceforge.net/forum/forum.php?thread_id=1911662&amp;forum_id=10226
382 http://sourceforge.net/forum/forum.php?thread_id=1911662&amp;forum_id=10226
346
383
347 </t>
384 ?</t>
348 <t tx="vivainio.20080222201226">1+2
385 <t tx="vivainio.20080223134433">
349 print "hello"
386 Declaring custom push-to-ipython handlers
350 3+4
387 =========================================
351
388
352 def f(x):
389 Sometimes, you might want to configure what alt+I on a node does. You can do
353 return x.upper()
390 that by creating your own push function and expose it using
391 ipy_leo.expose_ileo_push(f, priority). The function should check whether the
392 node should by handled by it and raise IPython.ipapi.TryNext if it will not do
393 the handling.
354
394
355 f('hello world')</t>
395 This would print an uppercase version of node body if the node headline ends
356 <t tx="vivainio.20080222202211"></t>
396 with U (yes, this is completely useless!)
357 <t tx="vivainio.20080222202211.1">@cl rfile
397
358 hello
398 def push_upcase(node):
359 world
399 if not node.h.endswith('U'):
360 and whatever</t>
400 raise TryNext
361 <t tx="vivainio.20080222202211.2"></t>
401 print node.b.upper()
402
403 expose_ileo_push(push_upcase, 12)
404
405 (the priority should be between 0-100 - typically, you don't need to care about
406 it and can omit the argument altogether)
407 </t>
362 </tnodes>
408 </tnodes>
363 </leo_file>
409 </leo_file>
General Comments 0
You need to be logged in to leave comments. Login now