##// END OF EJS Templates
Cleanup docs
Fernando Perez -
Show More
@@ -29,35 +29,35 b' import IPython.ipapi'
29 29 ip = IPython.ipapi.get()
30 30
31 31 def ankka_f(self, arg):
32 print "Ankka",self,"says uppercase:",arg.upper()
32 print 'Ankka',self,'says uppercase:',arg.upper()
33 33
34 ip.expose_magic("ankka",ankka_f)
34 ip.expose_magic('ankka',ankka_f)
35 35
36 36 ip.magic('alias sayhi echo "Testing, hi ok"')
37 37 ip.magic('alias helloworld echo "Hello world"')
38 38 ip.system('pwd')
39 39
40 40 ip.ex('import re')
41 ip.ex("""
41 ip.ex('''
42 42 def funcci(a,b):
43 43 print a+b
44 44 print funcci(3,4)
45 """)
46 ip.ex("funcci(348,9)")
45 ''')
46 ip.ex('funcci(348,9)')
47 47
48 48 def jed_editor(self,filename, linenum=None):
49 print "Calling my own editor, jed ... via hook!"
49 print 'Calling my own editor, jed ... via hook!'
50 50 import os
51 51 if linenum is None: linenum = 0
52 52 os.system('jed +%d %s' % (linenum, filename))
53 print "exiting jed"
53 print 'exiting jed'
54 54
55 55 ip.set_hook('editor',jed_editor)
56 56
57 57 o = ip.options
58 58 o.autocall = 2 # FULL autocall mode
59 59
60 print "done!"
60 print 'done!'
61 61 """
62 62
63 63 #-----------------------------------------------------------------------------
@@ -86,6 +86,7 b' class TryNext(Exception):'
86 86 self.args = args
87 87 self.kwargs = kwargs
88 88
89
89 90 class UsageError(Exception):
90 91 """ Error in magic function arguments, etc.
91 92
@@ -93,6 +94,7 b' class UsageError(Exception):'
93 94 nevertheless interrupt a macro / batch file.
94 95 """
95 96
97
96 98 class IPyAutocall:
97 99 """ Instances of this class are always autocalled
98 100
@@ -109,7 +111,6 b' class IPyAutocall:'
109 111 self._ip = ip
110 112
111 113
112
113 114 class IPythonNotRunning:
114 115 """Dummy do-nothing class.
115 116
@@ -161,7 +162,8 b' def get(allow_dummy=False,dummy_warn=True):'
161 162 _RECENT_IP = IPythonNotRunning(dummy_warn)
162 163 return _RECENT_IP
163 164
164 class IPApi:
165
166 class IPApi(object):
165 167 """ The actual API class for configuring IPython
166 168
167 169 You should do all of the IPython configuration by getting an IPApi object
@@ -225,22 +227,23 b' class IPApi:'
225 227 options = property(get_options,None,None,get_options.__doc__)
226 228
227 229 def expose_magic(self,magicname, func):
228 ''' Expose own function as magic function for ipython
230 """Expose own function as magic function for ipython
229 231
230 232 def foo_impl(self,parameter_s=''):
231 """My very own magic!. (Use docstrings, IPython reads them)."""
232 print 'Magic function. Passed parameter is between < >: <'+parameter_s+'>'
233 'My very own magic!. (Use docstrings, IPython reads them).'
234 print 'Magic function. Passed parameter is between < >:'
235 print '<%s>' % parameter_s
233 236 print 'The self object is:',self
234 237
235 ipapi.expose_magic("foo",foo_impl)
236 '''
237
238 ipapi.expose_magic('foo',foo_impl)
239 """
240
238 241 import new
239 242 im = new.instancemethod(func,self.IP, self.IP.__class__)
240 243 old = getattr(self.IP, "magic_" + magicname, None)
241 244 if old:
242 self.dbg.debug_stack("Magic redefinition '%s', old %s" % (magicname,
243 old))
245 self.dbg.debug_stack("Magic redefinition '%s', old %s" %
246 (magicname,old) )
244 247
245 248 setattr(self.IP, "magic_" + magicname, im)
246 249
General Comments 0
You need to be logged in to leave comments. Login now