From 65cdbdffce0648e7be01fb6262924a4fbf2d4f5b 2008-04-09 19:43:38 From: Ville M. Vainio Date: 2008-04-09 19:43:38 Subject: [PATCH] %magic: -rest argument generates restructuredtext output and returns it. indent mglob docstring --- diff --git a/IPython/Magic.py b/IPython/Magic.py index c6510e6..2fb106c 100644 --- a/IPython/Magic.py +++ b/IPython/Magic.py @@ -147,7 +147,7 @@ license. To use profiling, please install"python2.3-profiler" from non-free.""") filter(inst_magic,self.__dict__.keys()) + \ filter(inst_bound_magic,self.__class__.__dict__.keys()) out = [] - for fn in magics: + for fn in Set(magics): out.append(fn.replace('magic_','',1)) out.sort() return out @@ -386,7 +386,10 @@ license. To use profiling, please install"python2.3-profiler" from non-free.""") return None def magic_magic(self, parameter_s = ''): - """Print information about the magic function system.""" + """Print information about the magic function system. + + Supported formats: -latex, -brief, -rest + """ mode = '' try: @@ -394,6 +397,9 @@ license. To use profiling, please install"python2.3-profiler" from non-free.""") mode = 'latex' if parameter_s.split()[0] == '-brief': mode = 'brief' + if parameter_s.split()[0] == '-rest': + mode = 'rest' + rest_docs = [] except: pass @@ -414,12 +420,21 @@ license. To use profiling, please install"python2.3-profiler" from non-free.""") else: fndoc = 'No documentation' else: - fndoc = fn.__doc__ + fndoc = fn.__doc__.rstrip() + + if mode == 'rest': + rest_docs.append('**%s%s**::\n\n\t%s\n\n' %(self.shell.ESC_MAGIC, + fname,fndoc)) + + else: + magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC, + fname,fndoc)) - magic_docs.append('%s%s:\n\t%s\n' %(self.shell.ESC_MAGIC, - fname,fndoc)) magic_docs = ''.join(magic_docs) + if mode == 'rest': + return "".join(rest_docs) + if mode == 'latex': print self.format_latex(magic_docs) return diff --git a/IPython/external/mglob.py b/IPython/external/mglob.py index 37d6a6c..f5e436c 100644 --- a/IPython/external/mglob.py +++ b/IPython/external/mglob.py @@ -34,35 +34,35 @@ License: MIT Open Source license #Assigned in variable for "usage" printing convenience" globsyntax = """\ -This program allows specifying filenames with "mglob" mechanism. -Supported syntax in globs (wilcard matching patterns):: - - *.cpp ?ellowo* - - obvious. Differs from normal glob in that dirs are not included. - Unix users might want to write this as: "*.cpp" "?ellowo*" - rec:/usr/share=*.txt,*.doc - - get all *.txt and *.doc under /usr/share, - recursively - rec:/usr/share - - All files under /usr/share, recursively - rec:*.py - - All .py files under current working dir, recursively - foo - - File or dir foo - !*.bak readme* - - readme*, exclude files ending with .bak - !.svn/ !.hg/ !*_Data/ rec:. - - Skip .svn, .hg, foo_Data dirs (and their subdirs) in recurse. - Trailing / is the key, \ does not work! - dir:foo - - the directory foo if it exists (not files in foo) - dir:* - - all directories in current folder - foo.py bar.* !h* rec:*.py - - Obvious. !h* exclusion only applies for rec:*.py. - foo.py is *not* included twice. - @filelist.txt - - All files listed in 'filelist.txt' file, on separate lines. + This program allows specifying filenames with "mglob" mechanism. + Supported syntax in globs (wilcard matching patterns):: + + *.cpp ?ellowo* + - obvious. Differs from normal glob in that dirs are not included. + Unix users might want to write this as: "*.cpp" "?ellowo*" + rec:/usr/share=*.txt,*.doc + - get all *.txt and *.doc under /usr/share, + recursively + rec:/usr/share + - All files under /usr/share, recursively + rec:*.py + - All .py files under current working dir, recursively + foo + - File or dir foo + !*.bak readme* + - readme*, exclude files ending with .bak + !.svn/ !.hg/ !*_Data/ rec:. + - Skip .svn, .hg, foo_Data dirs (and their subdirs) in recurse. + Trailing / is the key, \ does not work! + dir:foo + - the directory foo if it exists (not files in foo) + dir:* + - all directories in current folder + foo.py bar.* !h* rec:*.py + - Obvious. !h* exclusion only applies for rec:*.py. + foo.py is *not* included twice. + @filelist.txt + - All files listed in 'filelist.txt' file, on separate lines. """