From c139a83bdcb3d899e7022e20b5c17312f58b63ce 2012-06-24 14:13:50 From: Carlos Cordoba Date: 2012-06-24 14:13:50 Subject: [PATCH] Make interactive_usage a bit more rst friendly All paragraphs are correctly aligned so that it can be shown in rst viewers without problems. --- diff --git a/IPython/core/usage.py b/IPython/core/usage.py index e9d4ef9..493d7fb 100644 --- a/IPython/core/usage.py +++ b/IPython/core/usage.py @@ -74,6 +74,7 @@ At your system command line, type 'ipython -h' to see the command line options available. This document only describes interactive features. MAIN FEATURES +------------- * Access to the standard Python help. As of Python 2.1, a help system is available with access to object docstrings and the Python manuals. Simply @@ -116,13 +117,13 @@ MAIN FEATURES * Search previous command history in two ways (also requires readline): - Start typing, and then use Ctrl-p (previous,up) and Ctrl-n (next,down) to - search through only the history items that match what you've typed so - far. If you use Ctrl-p/Ctrl-n at a blank prompt, they just behave like - normal arrow keys. + search through only the history items that match what you've typed so + far. If you use Ctrl-p/Ctrl-n at a blank prompt, they just behave like + normal arrow keys. - Hit Ctrl-r: opens a search prompt. Begin typing and the system searches - your history for lines that match what you've typed so far, completing as - much as it can. + your history for lines that match what you've typed so far, completing as + much as it can. - %hist: search history by index (this does *not* require readline). @@ -189,52 +190,68 @@ MAIN FEATURES * Auto-parentheses and auto-quotes (adapted from Nathan Gray's LazyPython) - 1. Auto-parentheses - Callable objects (i.e. functions, methods, etc) can be invoked like - this (notice the commas between the arguments): - In [1]: callable_ob arg1, arg2, arg3 - and the input will be translated to this: - ------> callable_ob(arg1, arg2, arg3) - This feature is off by default (in rare cases it can produce - undesirable side-effects), but you can activate it at the command-line - by starting IPython with `--autocall 1`, set it permanently in your - configuration file, or turn on at runtime with `%autocall 1`. - - You can force auto-parentheses by using '/' as the first character - of a line. For example: - In [1]: /globals # becomes 'globals()' - Note that the '/' MUST be the first character on the line! This - won't work: - In [2]: print /globals # syntax error - - In most cases the automatic algorithm should work, so you should - rarely need to explicitly invoke /. One notable exception is if you - are trying to call a function with a list of tuples as arguments (the - parenthesis will confuse IPython): - In [1]: zip (1,2,3),(4,5,6) # won't work - but this will work: - In [2]: /zip (1,2,3),(4,5,6) - ------> zip ((1,2,3),(4,5,6)) - Out[2]= [(1, 4), (2, 5), (3, 6)] - - IPython tells you that it has altered your command line by - displaying the new command line preceded by -->. e.g.: - In [18]: callable list - -------> callable (list) - - 2. Auto-Quoting - You can force auto-quoting of a function's arguments by using ',' as - the first character of a line. For example: - In [1]: ,my_function /home/me # becomes my_function("/home/me") - - If you use ';' instead, the whole argument is quoted as a single - string (while ',' splits on whitespace): - In [2]: ,my_function a b c # becomes my_function("a","b","c") - In [3]: ;my_function a b c # becomes my_function("a b c") - - Note that the ',' MUST be the first character on the line! This - won't work: - In [4]: x = ,my_function /home/me # syntax error + 1. Auto-parentheses + + Callable objects (i.e. functions, methods, etc) can be invoked like + this (notice the commas between the arguments):: + + In [1]: callable_ob arg1, arg2, arg3 + + and the input will be translated to this:: + + callable_ob(arg1, arg2, arg3) + + This feature is off by default (in rare cases it can produce + undesirable side-effects), but you can activate it at the command-line + by starting IPython with `--autocall 1`, set it permanently in your + configuration file, or turn on at runtime with `%autocall 1`. + + You can force auto-parentheses by using '/' as the first character + of a line. For example:: + + In [1]: /globals # becomes 'globals()' + + Note that the '/' MUST be the first character on the line! This + won't work:: + + In [2]: print /globals # syntax error + + In most cases the automatic algorithm should work, so you should + rarely need to explicitly invoke /. One notable exception is if you + are trying to call a function with a list of tuples as arguments (the + parenthesis will confuse IPython):: + + In [1]: zip (1,2,3),(4,5,6) # won't work + + but this will work:: + + In [2]: /zip (1,2,3),(4,5,6) + ------> zip ((1,2,3),(4,5,6)) + Out[2]= [(1, 4), (2, 5), (3, 6)] + + IPython tells you that it has altered your command line by + displaying the new command line preceded by -->. e.g.:: + + In [18]: callable list + -------> callable (list) + + 2. Auto-Quoting + + You can force auto-quoting of a function's arguments by using ',' as + the first character of a line. For example:: + + In [1]: ,my_function /home/me # becomes my_function("/home/me") + + If you use ';' instead, the whole argument is quoted as a single + string (while ',' splits on whitespace):: + + In [2]: ,my_function a b c # becomes my_function("a","b","c") + In [3]: ;my_function a b c # becomes my_function("a b c") + + Note that the ',' MUST be the first character on the line! This + won't work:: + + In [4]: x = ,my_function /home/me # syntax error """ interactive_usage_min = """\