comparison scripts/help/help.m @ 15026:ae42d5a67ed9

help.m: Added option '.' (dot); 'help .' lists all operators
author Sergey Dudoladov <sergey.dudoladov@gmail.com>
date Mon, 23 Jul 2012 12:18:07 +0400
parents f3d52523cde1
children fbecbce45898
comparison
equal deleted inserted replaced
15025:f23e60748072 15026:ae42d5a67ed9
17 ## <http://www.gnu.org/licenses/>. 17 ## <http://www.gnu.org/licenses/>.
18 18
19 ## -*- texinfo -*- 19 ## -*- texinfo -*-
20 ## @deftypefn {Command} {} help @var{name} 20 ## @deftypefn {Command} {} help @var{name}
21 ## @deftypefnx {Command} {} help @code{--list} 21 ## @deftypefnx {Command} {} help @code{--list}
22 ## @deftypefnx {Command} {} help @code{.}
22 ## Display the help text for @var{name}. For example, the command 23 ## Display the help text for @var{name}. For example, the command
23 ## @kbd{help help} prints a short message describing the @code{help} 24 ## @kbd{help help} prints a short message describing the @code{help}
24 ## command. 25 ## command.
25 ## 26 ##
26 ## Given the single argument @code{--list}, list all operators, 27 ## Given the single argument @code{--list}, list all operators,
27 ## keywords, built-in functions, and loadable functions available 28 ## keywords, built-in functions, and loadable functions available
29 ## in the current session of Octave.
30 ##
31 ## Given the single argument @code{.}, list all operators available
28 ## in the current session of Octave. 32 ## in the current session of Octave.
29 ## 33 ##
30 ## If invoked without any arguments, @code{help} display instructions 34 ## If invoked without any arguments, @code{help} display instructions
31 ## on how to access help from the command line. 35 ## on how to access help from the command line.
32 ## 36 ##
58 62
59 elseif (nargin == 1 && ischar (name)) 63 elseif (nargin == 1 && ischar (name))
60 64
61 if (strcmp (name, "--list")) 65 if (strcmp (name, "--list"))
62 tmp = do_list_functions (); 66 tmp = do_list_functions ();
67 if (nargout == 0)
68 printf ("%s", tmp);
69 else
70 retval = tmp;
71 endif
72 return;
73 endif
74
75 if (strcmp (name, "."))
76 tmp = do_list_operators ();
63 if (nargout == 0) 77 if (nargout == 0)
64 printf ("%s", tmp); 78 printf ("%s", tmp);
65 else 79 else
66 retval = tmp; 80 retval = tmp;
67 endif 81 endif
104 error ("help: invalid input\n"); 118 error ("help: invalid input\n");
105 endif 119 endif
106 120
107 endfunction 121 endfunction
108 122
123 function retval = do_list_operators ()
124
125 retval = sprintf ("*** operators:\n\n%s\n\n",
126 list_in_columns (__operators__ ()));
127 endfunction
128
109 function retval = do_list_functions () 129 function retval = do_list_functions ()
110 130
111 operators = sprintf ("*** operators:\n\n%s\n\n", 131 operators = do_list_operators ();
112 list_in_columns (__operators__ ()));
113 132
114 keywords = sprintf ("*** keywords:\n\n%s\n\n", 133 keywords = sprintf ("*** keywords:\n\n%s\n\n",
115 list_in_columns (__keywords__ ())); 134 list_in_columns (__keywords__ ()));
116 135
117 builtins = sprintf ("*** builtins:\n\n%s\n\n", 136 builtins = sprintf ("*** builtins:\n\n%s\n\n",