##// END OF EJS Templates
Fix documentation of functions using magic_arguments
Thomas Kluyver -
Show More
@@ -114,6 +114,7 b' class BasicMagics(Magics):'
114 Examples
114 Examples
115 --------
115 --------
116 ::
116 ::
117
117 In [1]: %alias_magic t timeit
118 In [1]: %alias_magic t timeit
118 Created `%t` as an alias for `%timeit`.
119 Created `%t` as an alias for `%timeit`.
119 Created `%%t` as an alias for `%%timeit`.
120 Created `%%t` as an alias for `%%timeit`.
@@ -68,6 +68,7 b' from IPython.core import magic_arguments'
68 from IPython.core.magic import Magics, magics_class, cell_magic
68 from IPython.core.magic import Magics, magics_class, cell_magic
69 from IPython.utils import py3compat
69 from IPython.utils import py3compat
70 from IPython.utils.path import get_ipython_cache_dir
70 from IPython.utils.path import get_ipython_cache_dir
71 from IPython.utils.text import dedent
71
72
72 import Cython
73 import Cython
73 from Cython.Compiler.Errors import CompileError
74 from Cython.Compiler.Errors import CompileError
@@ -331,9 +332,12 b' class CythonMagics(Magics):'
331 return html
332 return html
332
333
333 __doc__ = __doc__.format(
334 __doc__ = __doc__.format(
334 CYTHON_DOC = ' '*8 + CythonMagics.cython.__doc__,
335 # rST doesn't see the -+ flag as part of an option list, so we
335 CYTHON_INLINE_DOC = ' '*8 + CythonMagics.cython_inline.__doc__,
336 # hide it from the module-level docstring.
336 CYTHON_PYXIMPORT_DOC = ' '*8 + CythonMagics.cython_pyximport.__doc__,
337 CYTHON_DOC = dedent(CythonMagics.cython.__doc__\
338 .replace('-+, --cplus','--cplus ')),
339 CYTHON_INLINE_DOC = dedent(CythonMagics.cython_inline.__doc__),
340 CYTHON_PYXIMPORT_DOC = dedent(CythonMagics.cython_pyximport.__doc__),
337 )
341 )
338
342
339 def load_ipython_extension(ip):
343 def load_ipython_extension(ip):
@@ -55,6 +55,7 b' from IPython.core.magic_arguments import ('
55 argument, magic_arguments, parse_argstring
55 argument, magic_arguments, parse_argstring
56 )
56 )
57 from IPython.utils.py3compat import unicode_to_str
57 from IPython.utils.py3compat import unicode_to_str
58 from IPython.utils.text import dedent
58
59
59 class OctaveMagicError(oct2py.Oct2PyError):
60 class OctaveMagicError(oct2py.Oct2PyError):
60 pass
61 pass
@@ -145,6 +146,8 b' class OctaveMagics(Magics):'
145 '''
146 '''
146 Line-level magic that pulls a variable from Octave.
147 Line-level magic that pulls a variable from Octave.
147
148
149 ::
150
148 In [18]: _ = %octave x = [1 2; 3 4]; y = 'hello'
151 In [18]: _ = %octave x = [1 2; 3 4]; y = 'hello'
149
152
150 In [19]: %octave_pull x y
153 In [19]: %octave_pull x y
@@ -195,7 +198,7 b' class OctaveMagics(Magics):'
195 def octave(self, line, cell=None, local_ns=None):
198 def octave(self, line, cell=None, local_ns=None):
196 '''
199 '''
197 Execute code in Octave, and pull some of the results back into the
200 Execute code in Octave, and pull some of the results back into the
198 Python namespace.
201 Python namespace::
199
202
200 In [9]: %octave X = [1 2; 3 4]; mean(X)
203 In [9]: %octave X = [1 2; 3 4]; mean(X)
201 Out[9]: array([[ 2., 3.]])
204 Out[9]: array([[ 2., 3.]])
@@ -209,9 +212,9 b' class OctaveMagics(Magics):'
209
212
210 -2*x^4 - 1*x^3 + 0*x^2 + 1*x^1 + 2
213 -2*x^4 - 1*x^3 + 0*x^2 + 1*x^1 + 2
211
214
212 In the notebook, plots are published as the output of the cell, e.g.
215 In the notebook, plots are published as the output of the cell, e.g.::
213
216
214 %octave plot([1 2 3], [4 5 6])
217 %octave plot([1 2 3], [4 5 6])
215
218
216 will create a line plot.
219 will create a line plot.
217
220
@@ -360,9 +363,9 b' class OctaveMagics(Magics):'
360
363
361
364
362 __doc__ = __doc__.format(
365 __doc__ = __doc__.format(
363 OCTAVE_DOC = ' '*8 + OctaveMagics.octave.__doc__,
366 OCTAVE_DOC = dedent(OctaveMagics.octave.__doc__),
364 OCTAVE_PUSH_DOC = ' '*8 + OctaveMagics.octave_push.__doc__,
367 OCTAVE_PUSH_DOC = dedent(OctaveMagics.octave_push.__doc__),
365 OCTAVE_PULL_DOC = ' '*8 + OctaveMagics.octave_pull.__doc__
368 OCTAVE_PULL_DOC = dedent(OctaveMagics.octave_pull.__doc__)
366 )
369 )
367
370
368
371
@@ -75,6 +75,7 b' from IPython.core.magic_arguments import ('
75 from IPython.external.simplegeneric import generic
75 from IPython.external.simplegeneric import generic
76 from IPython.utils.py3compat import (str_to_unicode, unicode_to_str, PY3,
76 from IPython.utils.py3compat import (str_to_unicode, unicode_to_str, PY3,
77 unicode_type)
77 unicode_type)
78 from IPython.utils.text import dedent
78
79
79 class RInterpreterError(ri.RRuntimeError):
80 class RInterpreterError(ri.RRuntimeError):
80 """An error when running R code in a %%R magic cell."""
81 """An error when running R code in a %%R magic cell."""
@@ -679,10 +680,10 b' class RMagics(Magics):'
679 return self.Rconverter(result, dataframe=False)
680 return self.Rconverter(result, dataframe=False)
680
681
681 __doc__ = __doc__.format(
682 __doc__ = __doc__.format(
682 R_DOC = ' '*8 + RMagics.R.__doc__,
683 R_DOC = dedent(RMagics.R.__doc__),
683 RPUSH_DOC = ' '*8 + RMagics.Rpush.__doc__,
684 RPUSH_DOC = dedent(RMagics.Rpush.__doc__),
684 RPULL_DOC = ' '*8 + RMagics.Rpull.__doc__,
685 RPULL_DOC = dedent(RMagics.Rpull.__doc__),
685 RGET_DOC = ' '*8 + RMagics.Rget.__doc__
686 RGET_DOC = dedent(RMagics.Rget.__doc__)
686 )
687 )
687
688
688
689
@@ -46,6 +46,7 b' from IPython.core.error import UsageError'
46 from IPython.core.magic import Magics
46 from IPython.core.magic import Magics
47 from IPython.core import magic_arguments
47 from IPython.core import magic_arguments
48 from IPython.testing.skipdoctest import skip_doctest
48 from IPython.testing.skipdoctest import skip_doctest
49 from IPython.utils.text import dedent
49
50
50 #-----------------------------------------------------------------------------
51 #-----------------------------------------------------------------------------
51 # Definitions of magic functions for use with IPython
52 # Definitions of magic functions for use with IPython
@@ -108,13 +109,11 b' def output_args(f):'
108
109
109 Choices are:
110 Choices are:
110
111
111 type: group outputs of all engines by type (stdout, stderr, displaypub, etc.).
112 **type**: group outputs of all engines by type (stdout, stderr, displaypub, etc.).
112
113 **engine**: display all output for each engine together.
113 engine: display all output for each engine together.
114 **order**: like type, but individual displaypub output from each engine is collated.
114
115 For example, if multiple plots are generated by each engine, the first
115 order: like type, but individual displaypub output from each engine is collated.
116 figure of each engine will be displayed, then the second of each, etc.
116 For example, if multiple plots are generated by each engine, the first
117 figure of each engine will be displayed, then the second of each, etc.
118 """
117 """
119 ),
118 ),
120 magic_arguments.argument('-o', '--out', dest='save_name', type=str,
119 magic_arguments.argument('-o', '--out', dest='save_name', type=str,
@@ -435,8 +434,8 b' class ParallelMagics(Magics):'
435
434
436
435
437 __doc__ = __doc__.format(
436 __doc__ = __doc__.format(
438 AUTOPX_DOC = ' '*8 + ParallelMagics.autopx.__doc__,
437 AUTOPX_DOC = dedent(ParallelMagics.autopx.__doc__),
439 PX_DOC = ' '*8 + ParallelMagics.px.__doc__,
438 PX_DOC = dedent(ParallelMagics.px.__doc__),
440 RESULT_DOC = ' '*8 + ParallelMagics.result.__doc__,
439 RESULT_DOC = dedent(ParallelMagics.result.__doc__),
441 CONFIG_DOC = ' '*8 + ParallelMagics.pxconfig.__doc__,
440 CONFIG_DOC = dedent(ParallelMagics.pxconfig.__doc__),
442 )
441 )
General Comments 0
You need to be logged in to leave comments. Login now