Mercurial > octave
annotate scripts/help/help.m @ 22227:ab139f0733b9
Document that "help OPERATOR" needs quotes around OPERATOR (bug #39349).
* help.m (help, do_list_operators): State that quotes are required.
* comma.m, paren.m, semicolon.m: Move do deprecated/ directory
from help directory.
* scripts/deprecated/module.mk: Add comma.m, paren.m, semicolon.m
to deprecated directory.
* scripts/help/module.mk: Remove comma.m, paren.m, semicolon.m
from help directory.
author | Lachlan Andrew <lachlanbis@gmail.com> |
---|---|
date | Sun, 12 Jun 2016 19:38:22 +1000 |
parents | ffad2baa90f7 |
children | bac0d6f07a3e |
rev | line source |
---|---|
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
1 ## Copyright (C) 2009-2015 Søren Hauberg |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
2 ## |
11104 | 3 ## This file is part of Octave. |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
6 ## under the terms of the GNU General Public License as published by |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
8 ## your option) any later version. |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
9 ## |
11104 | 10 ## Octave is distributed in the hope that it will be useful, but |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
13 ## General Public License for more details. |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
14 ## |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
15 ## You should have received a copy of the GNU General Public License |
11104 | 16 ## along with Octave; see the file COPYING. If not, see |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
18 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
19 ## -*- texinfo -*- |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
20 ## @deftypefn {} {} help @var{name} |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
21 ## @deftypefnx {} {} help @code{--list} |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
22 ## @deftypefnx {} {} help @code{.} |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
23 ## @deftypefnx {} {} help |
19197
09bc8304f182
doc: Improvements to help() and info() docstrings.
Rik <rik@octave.org>
parents:
18110
diff
changeset
|
24 ## Display the help text for @var{name}. |
09bc8304f182
doc: Improvements to help() and info() docstrings.
Rik <rik@octave.org>
parents:
18110
diff
changeset
|
25 ## |
09bc8304f182
doc: Improvements to help() and info() docstrings.
Rik <rik@octave.org>
parents:
18110
diff
changeset
|
26 ## For example, the command @kbd{help help} prints a short message describing |
09bc8304f182
doc: Improvements to help() and info() docstrings.
Rik <rik@octave.org>
parents:
18110
diff
changeset
|
27 ## the @code{help} command. |
11565
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
28 ## |
20158
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
29 ## Given the single argument @code{--list}, list all operators, keywords, |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
30 ## built-in functions, and loadable functions available in the current session |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
31 ## of Octave. |
11565
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
32 ## |
20158
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
33 ## Given the single argument @code{.}, list all operators available in the |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
34 ## current session of Octave. |
15026
ae42d5a67ed9
help.m: Added option '.' (dot); 'help .' lists all operators
Sergey Dudoladov <sergey.dudoladov@gmail.com>
parents:
14363
diff
changeset
|
35 ## |
22227
ab139f0733b9
Document that "help OPERATOR" needs quotes around OPERATOR (bug #39349).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21758
diff
changeset
|
36 ## If invoked without any arguments, @code{help} displays instructions on how |
ab139f0733b9
Document that "help OPERATOR" needs quotes around OPERATOR (bug #39349).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21758
diff
changeset
|
37 ## to access help from the command line. |
11565
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
38 ## |
22227
ab139f0733b9
Document that "help OPERATOR" needs quotes around OPERATOR (bug #39349).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21758
diff
changeset
|
39 ## The help command can provide information about most operators, but |
ab139f0733b9
Document that "help OPERATOR" needs quotes around OPERATOR (bug #39349).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21758
diff
changeset
|
40 ## @var{name} must be enclosed by single or double quotes to prevent |
ab139f0733b9
Document that "help OPERATOR" needs quotes around OPERATOR (bug #39349).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21758
diff
changeset
|
41 ## the Octave interpreter from acting on @var{name}. For example, |
ab139f0733b9
Document that "help OPERATOR" needs quotes around OPERATOR (bug #39349).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21758
diff
changeset
|
42 ## @code{help "+"} displays help on the addition operator. |
19197
09bc8304f182
doc: Improvements to help() and info() docstrings.
Rik <rik@octave.org>
parents:
18110
diff
changeset
|
43 ## @seealso{doc, lookfor, which, info} |
10625
07933067e4ab
help.m: Allow docstring to be returned as output, and correct docstring.
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
44 ## @end deftypefn |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
45 |
10632
69a715c81eab
help.m: avoid unnecessary use of varargout
John W. Eaton <jwe@octave.org>
parents:
10625
diff
changeset
|
46 function retval = help (name) |
8748
d1eed318100f
help.m: shorten default help text
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
47 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
48 if (nargin == 0) |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
49 |
15227
fbecbce45898
also return help text as a string when nargin = 0 (bug #37183)
John W. Eaton <jwe@octave.org>
parents:
15026
diff
changeset
|
50 text = "\n\ |
8748
d1eed318100f
help.m: shorten default help text
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
51 For help with individual commands and functions type\n\ |
d1eed318100f
help.m: shorten default help text
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
52 \n\ |
d1eed318100f
help.m: shorten default help text
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
53 help NAME\n\ |
d1eed318100f
help.m: shorten default help text
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
54 \n\ |
d1eed318100f
help.m: shorten default help text
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
55 (replace NAME with the name of the command or function you would\n\ |
22227
ab139f0733b9
Document that "help OPERATOR" needs quotes around OPERATOR (bug #39349).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21758
diff
changeset
|
56 like to learn more about; for an operator, enclose NAME in quotes).\n\ |
8748
d1eed318100f
help.m: shorten default help text
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
57 \n\ |
22227
ab139f0733b9
Document that "help OPERATOR" needs quotes around OPERATOR (bug #39349).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21758
diff
changeset
|
58 For a more detailed introduction to GNU Octave, consult the manual.\n\ |
ab139f0733b9
Document that "help OPERATOR" needs quotes around OPERATOR (bug #39349).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21758
diff
changeset
|
59 The manual may be read from the prompt by typing\n\ |
8748
d1eed318100f
help.m: shorten default help text
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
60 \n\ |
d1eed318100f
help.m: shorten default help text
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
61 doc\n\ |
d1eed318100f
help.m: shorten default help text
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
62 \n\ |
d1eed318100f
help.m: shorten default help text
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
63 GNU Octave is supported and developed by its user community.\n\ |
15227
fbecbce45898
also return help text as a string when nargin = 0 (bug #37183)
John W. Eaton <jwe@octave.org>
parents:
15026
diff
changeset
|
64 For more information visit http://www.octave.org.\n\n"; |
fbecbce45898
also return help text as a string when nargin = 0 (bug #37183)
John W. Eaton <jwe@octave.org>
parents:
15026
diff
changeset
|
65 |
fbecbce45898
also return help text as a string when nargin = 0 (bug #37183)
John W. Eaton <jwe@octave.org>
parents:
15026
diff
changeset
|
66 if (nargout == 0) |
21634
96518f623c91
Backed out changeset dcf8922b724b
Mike Miller <mtmiller@octave.org>
parents:
21633
diff
changeset
|
67 puts (text); |
15227
fbecbce45898
also return help text as a string when nargin = 0 (bug #37183)
John W. Eaton <jwe@octave.org>
parents:
15026
diff
changeset
|
68 else |
fbecbce45898
also return help text as a string when nargin = 0 (bug #37183)
John W. Eaton <jwe@octave.org>
parents:
15026
diff
changeset
|
69 retval = text; |
fbecbce45898
also return help text as a string when nargin = 0 (bug #37183)
John W. Eaton <jwe@octave.org>
parents:
15026
diff
changeset
|
70 endif |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
71 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
72 elseif (nargin == 1 && ischar (name)) |
8748
d1eed318100f
help.m: shorten default help text
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
73 |
11565
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
74 if (strcmp (name, "--list")) |
19197
09bc8304f182
doc: Improvements to help() and info() docstrings.
Rik <rik@octave.org>
parents:
18110
diff
changeset
|
75 list = do_list_functions (); |
11565
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
76 if (nargout == 0) |
21634
96518f623c91
Backed out changeset dcf8922b724b
Mike Miller <mtmiller@octave.org>
parents:
21633
diff
changeset
|
77 printf ("%s", list); |
11565
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
78 else |
19197
09bc8304f182
doc: Improvements to help() and info() docstrings.
Rik <rik@octave.org>
parents:
18110
diff
changeset
|
79 retval = list; |
11565
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
80 endif |
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
81 return; |
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
82 endif |
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
83 |
15026
ae42d5a67ed9
help.m: Added option '.' (dot); 'help .' lists all operators
Sergey Dudoladov <sergey.dudoladov@gmail.com>
parents:
14363
diff
changeset
|
84 if (strcmp (name, ".")) |
19197
09bc8304f182
doc: Improvements to help() and info() docstrings.
Rik <rik@octave.org>
parents:
18110
diff
changeset
|
85 list = do_list_operators (); |
15026
ae42d5a67ed9
help.m: Added option '.' (dot); 'help .' lists all operators
Sergey Dudoladov <sergey.dudoladov@gmail.com>
parents:
14363
diff
changeset
|
86 if (nargout == 0) |
21634
96518f623c91
Backed out changeset dcf8922b724b
Mike Miller <mtmiller@octave.org>
parents:
21633
diff
changeset
|
87 printf ("%s", list); |
15026
ae42d5a67ed9
help.m: Added option '.' (dot); 'help .' lists all operators
Sergey Dudoladov <sergey.dudoladov@gmail.com>
parents:
14363
diff
changeset
|
88 else |
19197
09bc8304f182
doc: Improvements to help() and info() docstrings.
Rik <rik@octave.org>
parents:
18110
diff
changeset
|
89 retval = list; |
15026
ae42d5a67ed9
help.m: Added option '.' (dot); 'help .' lists all operators
Sergey Dudoladov <sergey.dudoladov@gmail.com>
parents:
14363
diff
changeset
|
90 endif |
ae42d5a67ed9
help.m: Added option '.' (dot); 'help .' lists all operators
Sergey Dudoladov <sergey.dudoladov@gmail.com>
parents:
14363
diff
changeset
|
91 return; |
ae42d5a67ed9
help.m: Added option '.' (dot); 'help .' lists all operators
Sergey Dudoladov <sergey.dudoladov@gmail.com>
parents:
14363
diff
changeset
|
92 endif |
ae42d5a67ed9
help.m: Added option '.' (dot); 'help .' lists all operators
Sergey Dudoladov <sergey.dudoladov@gmail.com>
parents:
14363
diff
changeset
|
93 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
94 ## Get help text |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
95 [text, format] = get_help_text (name); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11567
diff
changeset
|
96 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
97 ## Take action depending on help text format |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
98 switch (lower (format)) |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
99 case "plain text" |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
100 status = 0; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
101 case "texinfo" |
8768
e0fbf17a17bb
__makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents:
8748
diff
changeset
|
102 [text, status] = __makeinfo__ (text, "plain text"); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
103 case "html" |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
104 [text, status] = strip_html_tags (text); |
8631
52956d669506
Display sensible error message when the help text of an undocumented function is requested
Soren Hauberg <hauberg@gmail.com>
parents:
8630
diff
changeset
|
105 case "not documented" |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
106 error ("help: '%s' is not documented\n", name); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
107 case "not found" |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
108 do_contents (name); |
10549 | 109 return; |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
110 otherwise |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
111 error ("help: internal error: unsupported help text format: '%s'\n", format); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
112 endswitch |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11567
diff
changeset
|
113 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
114 ## Print text |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
115 if (status != 0) |
8768
e0fbf17a17bb
__makeinfo__.m: rename from makeinfo.m
John W. Eaton <jwe@octave.org>
parents:
8748
diff
changeset
|
116 warning ("help: Texinfo formatting filter exited abnormally; raw Texinfo source of help text follows...\n"); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
117 endif |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
118 |
10625
07933067e4ab
help.m: Allow docstring to be returned as output, and correct docstring.
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
119 if (nargout == 0) |
21685
fc8cc7730514
help: evaluate call to 'which' in the correct context
Mike Miller <mtmiller@octave.org>
parents:
21634
diff
changeset
|
120 evalin ("caller", ["which (\"" name "\")"]); |
21634
96518f623c91
Backed out changeset dcf8922b724b
Mike Miller <mtmiller@octave.org>
parents:
21633
diff
changeset
|
121 printf ("\n%s\n%s", text, __additional_help_message__ ()); |
10625
07933067e4ab
help.m: Allow docstring to be returned as output, and correct docstring.
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
122 else |
10632
69a715c81eab
help.m: avoid unnecessary use of varargout
John W. Eaton <jwe@octave.org>
parents:
10625
diff
changeset
|
123 retval = text; |
10625
07933067e4ab
help.m: Allow docstring to be returned as output, and correct docstring.
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
124 endif |
8748
d1eed318100f
help.m: shorten default help text
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
125 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
126 else |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
127 error ("help: invalid input\n"); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
128 endif |
8748
d1eed318100f
help.m: shorten default help text
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
129 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
130 endfunction |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
diff
changeset
|
131 |
15026
ae42d5a67ed9
help.m: Added option '.' (dot); 'help .' lists all operators
Sergey Dudoladov <sergey.dudoladov@gmail.com>
parents:
14363
diff
changeset
|
132 function retval = do_list_operators () |
22227
ab139f0733b9
Document that "help OPERATOR" needs quotes around OPERATOR (bug #39349).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21758
diff
changeset
|
133 retval = sprintf ("*** operators:\n\n%s\n%s\n\n", |
ab139f0733b9
Document that "help OPERATOR" needs quotes around OPERATOR (bug #39349).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21758
diff
changeset
|
134 list_in_columns (__operators__ ()), |
ab139f0733b9
Document that "help OPERATOR" needs quotes around OPERATOR (bug #39349).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21758
diff
changeset
|
135 ["To obtain help on an operator, type\n"... |
ab139f0733b9
Document that "help OPERATOR" needs quotes around OPERATOR (bug #39349).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21758
diff
changeset
|
136 " help \"NAME\" or help 'NAME'"]); |
15026
ae42d5a67ed9
help.m: Added option '.' (dot); 'help .' lists all operators
Sergey Dudoladov <sergey.dudoladov@gmail.com>
parents:
14363
diff
changeset
|
137 endfunction |
ae42d5a67ed9
help.m: Added option '.' (dot); 'help .' lists all operators
Sergey Dudoladov <sergey.dudoladov@gmail.com>
parents:
14363
diff
changeset
|
138 |
11565
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
139 function retval = do_list_functions () |
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
140 |
15026
ae42d5a67ed9
help.m: Added option '.' (dot); 'help .' lists all operators
Sergey Dudoladov <sergey.dudoladov@gmail.com>
parents:
14363
diff
changeset
|
141 operators = do_list_operators (); |
11565
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
142 |
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
143 keywords = sprintf ("*** keywords:\n\n%s\n\n", |
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
144 list_in_columns (__keywords__ ())); |
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
145 |
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
146 builtins = sprintf ("*** builtins:\n\n%s\n\n", |
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
147 list_in_columns (__builtins__ ())); |
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
148 |
16724
b7667fcb9fbc
Substitute ostrsplit() for strsplit().
Ben Abbott <bpabbott@mac.com>
parents:
16403
diff
changeset
|
149 dirs = ostrsplit (path, pathsep); |
11565
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
150 flist = ""; |
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
151 for i = 2:numel (dirs) |
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
152 files = sort ({dir(fullfile (dirs{i}, "*.m")).name, ... |
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
153 dir(fullfile (dirs{i}, "*.oct")).name, ... |
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
154 dir(fullfile (dirs{i}, "*.mex")).name}); |
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
155 |
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
156 if (! isempty (files)) |
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
157 flist = sprintf ("%s*** functions in %s:\n\n%s\n\n", |
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
158 flist, dirs{i}, list_in_columns (files)); |
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
159 endif |
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
160 endfor |
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
161 |
16994
333243133364
Use matrix concatenation for strings, rather than cstrcat(), for clarity and performance.
Rik <rik@octave.org>
parents:
16724
diff
changeset
|
162 retval = [operators, keywords, builtins, flist]; |
11565
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
163 |
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
164 endfunction |
21c3e1370b82
implement --list option for help function
John W. Eaton <jwe@octave.org>
parents:
11563
diff
changeset
|
165 |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
166 function do_contents (name) |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
167 |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
168 found = false; |
8630
540165304f00
Allow displaying 'Contents.m' files.
Soren Hauberg <hauberg@gmail.com>
parents:
8575
diff
changeset
|
169 |
18110
2217bc116aa9
maint: Dummy merge with gui-release, ignoring all recent backout merges
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
18105
diff
changeset
|
170 dlist = dir_in_loadpath (name, "all"); |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
171 |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
172 for i = 1:numel (dlist) |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
173 fname = make_absolute_filename (fullfile (dlist{i}, "Contents.m")); |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
174 |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
175 [text, format] = get_help_text_from_file (fname); |
8630
540165304f00
Allow displaying 'Contents.m' files.
Soren Hauberg <hauberg@gmail.com>
parents:
8575
diff
changeset
|
176 |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
177 ## Take action depending on help text format |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
178 switch (lower (format)) |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
179 case "plain text" |
10549 | 180 status = 0; |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
181 case "texinfo" |
10549 | 182 [text, status] = __makeinfo__ (text, "plain text"); |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
183 case "html" |
10549 | 184 [text, status] = strip_html_tags (text); |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
185 endswitch |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
186 |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
187 if (! isempty (text)) |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
188 found = true; |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
189 ## Print text. |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
190 if (status != 0) |
10549 | 191 warning ("help: Texinfo formatting filter exited abnormally; raw Texinfo source of help text follows...\n"); |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
192 endif |
21634
96518f623c91
Backed out changeset dcf8922b724b
Mike Miller <mtmiller@octave.org>
parents:
21633
diff
changeset
|
193 printf ("%s:\n\n%s\n", fname, text); |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
194 endif |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
195 |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
196 endfor |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
197 |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
198 if (found) |
21634
96518f623c91
Backed out changeset dcf8922b724b
Mike Miller <mtmiller@octave.org>
parents:
21633
diff
changeset
|
199 puts (__additional_help_message__ ()); |
10445
62f8ae5ab2cc
warn about missing matlab funcs in help
Jaroslav Hajek <highegg@gmail.com>
parents:
9806
diff
changeset
|
200 else |
11215
8b2a47a99701
help: print message if function not found
John W. Eaton <jwe@octave.org>
parents:
11104
diff
changeset
|
201 msg = feval (missing_function_hook, name); |
8b2a47a99701
help: print message if function not found
John W. Eaton <jwe@octave.org>
parents:
11104
diff
changeset
|
202 |
8b2a47a99701
help: print message if function not found
John W. Eaton <jwe@octave.org>
parents:
11104
diff
changeset
|
203 if (isempty (msg)) |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
204 msg = sprintf ("'%s' not found", name); |
11215
8b2a47a99701
help: print message if function not found
John W. Eaton <jwe@octave.org>
parents:
11104
diff
changeset
|
205 endif |
8b2a47a99701
help: print message if function not found
John W. Eaton <jwe@octave.org>
parents:
11104
diff
changeset
|
206 |
8b2a47a99701
help: print message if function not found
John W. Eaton <jwe@octave.org>
parents:
11104
diff
changeset
|
207 error ("help: %s\n", msg); |
8630
540165304f00
Allow displaying 'Contents.m' files.
Soren Hauberg <hauberg@gmail.com>
parents:
8575
diff
changeset
|
208 endif |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9724
diff
changeset
|
209 |
8630
540165304f00
Allow displaying 'Contents.m' files.
Soren Hauberg <hauberg@gmail.com>
parents:
8575
diff
changeset
|
210 endfunction |
13763
85d63b6e49cf
help.m: Add functional tests
Rik <octave@nomad.inbox5.com>
parents:
12344
diff
changeset
|
211 |
85d63b6e49cf
help.m: Add functional tests
Rik <octave@nomad.inbox5.com>
parents:
12344
diff
changeset
|
212 |
14214
2fe0f5fa8cc3
Replace to-be-deprecated findstr occurrences with strfind.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
213 %!assert (! isempty (strfind (help ("ls"), "List directory contents"))) |
19197
09bc8304f182
doc: Improvements to help() and info() docstrings.
Rik <rik@octave.org>
parents:
18110
diff
changeset
|
214 %!assert (! isempty (strfind (help ("."), "||"))) |
09bc8304f182
doc: Improvements to help() and info() docstrings.
Rik <rik@octave.org>
parents:
18110
diff
changeset
|
215 |
09bc8304f182
doc: Improvements to help() and info() docstrings.
Rik <rik@octave.org>
parents:
18110
diff
changeset
|
216 ## Test input validation |
13763
85d63b6e49cf
help.m: Add functional tests
Rik <octave@nomad.inbox5.com>
parents:
12344
diff
changeset
|
217 %!error <invalid input> help (42) |
19197
09bc8304f182
doc: Improvements to help() and info() docstrings.
Rik <rik@octave.org>
parents:
18110
diff
changeset
|
218 %!error <invalid input> help ("abc", "def") |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
219 %!error <'_! UNLIKELY_FCN! _' not found> help ("_! UNLIKELY_FCN! _") |
21634
96518f623c91
Backed out changeset dcf8922b724b
Mike Miller <mtmiller@octave.org>
parents:
21633
diff
changeset
|
220 |