Mercurial > hg > octave-nkf
annotate src/help.cc @ 12519:91ccd08fe80c
Add gen_doc_cache, get_help_text, get_help_text_from_file, get_first_help_sentence to documentation.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Fri, 18 Mar 2011 14:38:46 -0700 |
parents | 7a5aacf65f81 |
children | 307e177dbaa8 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
11523 | 3 Copyright (C) 1993-2011 John W. Eaton |
1 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
1 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1 | 20 |
21 */ | |
22 | |
240 | 23 #ifdef HAVE_CONFIG_H |
1192 | 24 #include <config.h> |
1 | 25 #endif |
26 | |
1343 | 27 #include <cstdlib> |
28 #include <cstring> | |
29 | |
5769 | 30 #include <algorithm> |
3503 | 31 #include <iostream> |
32 #include <fstream> | |
5765 | 33 #include <sstream> |
1755 | 34 #include <string> |
35 | |
1295 | 36 #include <sys/types.h> |
37 #include <unistd.h> | |
1343 | 38 |
3295 | 39 #include "cmd-edit.h" |
40 #include "file-ops.h" | |
6253 | 41 #include "file-stat.h" |
2926 | 42 #include "oct-env.h" |
1755 | 43 #include "str-vec.h" |
44 | |
2492 | 45 #include <defaults.h> |
1352 | 46 #include "defun.h" |
47 #include "dirfns.h" | |
48 #include "error.h" | |
2202 | 49 #include "gripes.h" |
1352 | 50 #include "help.h" |
2177 | 51 #include "input.h" |
5832 | 52 #include "load-path.h" |
1755 | 53 #include "oct-obj.h" |
2976 | 54 #include "ov-usr-fcn.h" |
1352 | 55 #include "pager.h" |
3018 | 56 #include "parse.h" |
1466 | 57 #include "pathsearch.h" |
3295 | 58 #include "procstream.h" |
7336 | 59 #include "pt-pr-code.h" |
529 | 60 #include "sighandlers.h" |
61 #include "symtab.h" | |
2694 | 62 #include "syswait.h" |
1755 | 63 #include "toplev.h" |
8672
2a49c32d4322
allow help to work with files containing only comments
John W. Eaton <jwe@octave.org>
parents:
8631
diff
changeset
|
64 #include "unwind-prot.h" |
242 | 65 #include "utils.h" |
1352 | 66 #include "variables.h" |
3301 | 67 #include "version.h" |
5447 | 68 #include "quit.h" |
529 | 69 |
8861 | 70 // Name of the doc cache file specified on the command line. |
71 // (--doc-cache-file file) | |
72 std::string Vdoc_cache_file; | |
73 | |
2202 | 74 // Name of the info file specified on command line. |
75 // (--info-file file) | |
3523 | 76 std::string Vinfo_file; |
2202 | 77 |
78 // Name of the info reader we'd like to use. | |
79 // (--info-program program) | |
5794 | 80 std::string Vinfo_program; |
2202 | 81 |
3686 | 82 // Name of the makeinfo program to run. |
5794 | 83 static std::string Vmakeinfo_program = "makeinfo"; |
3686 | 84 |
2189 | 85 // If TRUE, don't print additional help message in help and usage |
86 // functions. | |
5794 | 87 static bool Vsuppress_verbose_help_message = false; |
2189 | 88 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
89 #include <map> |
3016 | 90 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
91 typedef std::map<std::string, std::string> map_type; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
92 typedef map_type::value_type pair_type; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
93 typedef map_type::const_iterator map_iter; |
3016 | 94 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
95 template<typename T, std::size_t z> |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
96 std::size_t |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
97 size (T const (&)[z]) |
1 | 98 { |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
99 return z; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
100 } |
1 | 101 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
102 // FIXME -- The descriptions could easily be in texinfo -- should they? |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
103 const static pair_type operators[] = |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
104 { |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
105 pair_type ("!", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
106 "Logical not operator. See also `~'.\n"), |
1 | 107 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
108 pair_type ("!=", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
109 "Logical not equals operator. See also `~='.\n"), |
1 | 110 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
111 pair_type ("\"", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
112 "String delimiter.\n"), |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
113 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
114 pair_type ("#", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
115 "Begin comment character. See also `%'."), |
1 | 116 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
117 pair_type ("%", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
118 "Begin comment charcter. See also `#'."), |
1 | 119 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
120 pair_type ("&", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
121 "Element by element logical and operator. See also `&&'."), |
1 | 122 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
123 pair_type ("&&", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
124 "Logical and operator (with short-circuit evaluation). See also `&'."), |
1 | 125 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
126 pair_type ("'", |
1 | 127 "Matrix transpose operator. For complex matrices, computes the\n\ |
128 complex conjugate (Hermitian) transpose. See also `.''\n\ | |
129 \n\ | |
130 The single quote character may also be used to delimit strings, but\n\ | |
131 it is better to use the double quote character, since that is never\n\ | |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
132 ambiguous"), |
1 | 133 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
134 pair_type ("(", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
135 "Array index or function argument delimiter."), |
1 | 136 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
137 pair_type (")", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
138 "Array index or function argument delimiter."), |
1 | 139 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
140 pair_type ("*", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
141 "Multiplication operator. See also `.*'"), |
1 | 142 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
143 pair_type ("**", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
144 "Power operator. See also `^', `.**', and `.^'"), |
1 | 145 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
146 pair_type ("+", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
147 "Addition operator."), |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
148 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
149 pair_type ("++", |
5339 | 150 "Increment operator. As in C, may be applied as a prefix or postfix\n\ |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
151 operator."), |
1 | 152 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
153 pair_type (",", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
154 "Array index, function argument, or command separator."), |
1 | 155 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
156 pair_type ("-", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
157 "Subtraction or unary negation operator."), |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
158 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
159 pair_type ("--", |
5339 | 160 "Decrement operator. As in C, may be applied as a prefix or postfix\n\ |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
161 operator."), |
1 | 162 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
163 pair_type (".'", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
164 "Matrix transpose operator. For complex matrices, computes the\n\ |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
165 transpose, *not* the complex conjugate transpose. See also `''."), |
1 | 166 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
167 pair_type (".*", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
168 "Element by element multiplication operator. See also `*'."), |
1 | 169 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
170 pair_type (".**", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
171 "Element by element power operator. See also `**', `^', and `.^'."), |
1 | 172 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
173 pair_type ("./", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
174 "Element by element division operator. See also `/' and `\\'."), |
1 | 175 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
176 pair_type (".^", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
177 "Element by element power operator. See also `**', `^', and `.^'."), |
1 | 178 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
179 pair_type ("/", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
180 "Right division. See also `\\' and `./'."), |
1 | 181 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
182 pair_type (":", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
183 "Select entire rows or columns of matrices."), |
1 | 184 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
185 pair_type (";", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
186 "Array row or command separator. See also `,'."), |
1 | 187 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
188 pair_type ("<", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
189 "Less than operator."), |
1 | 190 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
191 pair_type ("<=", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
192 "Less than or equals operator."), |
1 | 193 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
194 pair_type ("=", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
195 "Assignment operator."), |
1 | 196 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
197 pair_type ("==", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
198 "Equality test operator."), |
1 | 199 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
200 pair_type (">", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
201 "Greater than operator."), |
1 | 202 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
203 pair_type (">=", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
204 "Greater than or equals operator."), |
1 | 205 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
206 pair_type ("[", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
207 "Return list delimiter. See also `]'."), |
1 | 208 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
209 pair_type ("\\", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
210 "Left division operator. See also `/' and `./'."), |
1 | 211 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
212 pair_type ("]", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
213 "Return list delimiter. See also `['."), |
1 | 214 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
215 pair_type ("^", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
216 "Power operator. See also `**', `.^', and `.**.'"), |
1 | 217 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
218 pair_type ("|", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
219 "Element by element logical or operator. See also `||'."), |
1 | 220 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
221 pair_type ("||", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
222 "Logical or operator (with short-circuit evaluation). See also `|'."), |
1 | 223 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
224 pair_type ("~", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
225 "Logical not operator. See also `!' and `~'."), |
1 | 226 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
227 pair_type ("~=", |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
228 "Logical not equals operator. See also `!='."), |
1 | 229 }; |
230 | |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
231 const static pair_type keywords[] = |
1 | 232 { |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
233 pair_type ("break", |
5818 | 234 "-*- texinfo -*-\n\ |
11547 | 235 @deftypefn {Keyword} {} break\n\ |
5818 | 236 Exit the innermost enclosing do, while or for loop.\n\ |
237 @seealso{do, while, for, continue}\n\ | |
11547 | 238 @end deftypefn"), |
5040 | 239 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
240 pair_type ("case", |
5818 | 241 "-*- texinfo -*-\n\ |
11547 | 242 @deftypefn {Keyword} {} case @{@var{value}@}\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
243 A case statement in an switch. Octave cases are exclusive and do not\n\ |
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
244 fall-through as do C-language cases. A switch statement must have at least\n\ |
5818 | 245 one case. See @code{switch} for an example.\n\ |
246 @seealso{switch}\n\ | |
11547 | 247 @end deftypefn"), |
1 | 248 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
249 pair_type ("catch", |
5818 | 250 "-*- texinfo -*-\n\ |
11547 | 251 @deftypefn {Keyword} {} catch\n\ |
5818 | 252 Begin the cleanup part of a try-catch block.\n\ |
253 @seealso{try}\n\ | |
11547 | 254 @end deftypefn"), |
1489 | 255 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
256 pair_type ("continue", |
5818 | 257 "-*- texinfo -*-\n\ |
11547 | 258 @deftypefn {Keyword} {} continue\n\ |
5818 | 259 Jump to the end of the innermost enclosing do, while or for loop.\n\ |
260 @seealso{do, while, for, break}\n\ | |
11547 | 261 @end deftypefn"), |
5040 | 262 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
263 pair_type ("do", |
5818 | 264 "-*- texinfo -*-\n\ |
11547 | 265 @deftypefn {Keyword} {} do\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
266 Begin a do-until loop. This differs from a do-while loop in that the\n\ |
5818 | 267 body of the loop is executed at least once.\n\ |
268 @seealso{while}\n\ | |
11547 | 269 @end deftypefn"), |
1 | 270 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
271 pair_type ("else", |
5818 | 272 "-*- texinfo -*-\n\ |
11547 | 273 @deftypefn {Keyword} {} else\n\ |
5818 | 274 Alternate action for an if block. See @code{if} for an example.\n\ |
275 @seealso{if}\n\ | |
11547 | 276 @end deftypefn"), |
1 | 277 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
278 pair_type ("elseif", |
5818 | 279 "-*- texinfo -*-\n\ |
11547 | 280 @deftypefn {Keyword} {} elseif (@var{condition})\n\ |
5818 | 281 Alternate conditional test for an if block. See @code{if} for an example.\n\ |
282 @seealso{if}\n\ | |
11547 | 283 @end deftypefn"), |
1 | 284 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
285 pair_type ("end", |
5818 | 286 "-*- texinfo -*-\n\ |
11547 | 287 @deftypefn {Keyword} {} end\n\ |
10840 | 288 Mark the end of any @code{for}, @code{if}, @code{do}, @code{while}, or\n\ |
289 @code{function} block.\n\ | |
5818 | 290 @seealso{for, if, do, while, function}\n\ |
11547 | 291 @end deftypefn"), |
928 | 292 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
293 pair_type ("end_try_catch", |
5818 | 294 "-*- texinfo -*-\n\ |
11547 | 295 @deftypefn {Keyword} {} end_try_catch\n\ |
5818 | 296 Mark the end of an @code{try-catch} block.\n\ |
297 @seealso{try, catch}\n\ | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
298 @end deftypefn"), |
1489 | 299 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
300 pair_type ("end_unwind_protect", |
5818 | 301 "-*- texinfo -*-\n\ |
11547 | 302 @deftypefn {Keyword} {} end_unwind_protect\n\ |
5818 | 303 Mark the end of an unwind_protect block.\n\ |
304 @seealso{unwind_protect}\n\ | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
305 @end deftypefn"), |
1 | 306 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
307 pair_type ("endfor", |
5818 | 308 "-*- texinfo -*-\n\ |
11547 | 309 @deftypefn {Keyword} {} endfor\n\ |
5818 | 310 Mark the end of a for loop. See @code{for} for an example.\n\ |
311 @seealso{for}\n\ | |
11547 | 312 @end deftypefn"), |
1 | 313 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
314 pair_type ("endfunction", |
5818 | 315 "-*- texinfo -*-\n\ |
11547 | 316 @deftypefn {Keyword} {} endfunction\n\ |
5818 | 317 Mark the end of a function.\n\ |
318 @seealso{function}\n\ | |
11547 | 319 @end deftypefn"), |
1 | 320 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
321 pair_type ("endif", |
5818 | 322 "-*- texinfo -*-\n\ |
11547 | 323 @deftypefn {Keyword} {} endif\n\ |
5818 | 324 Mark the end of an if block. See @code{if} for an example.\n\ |
325 @seealso{if}\n\ | |
11547 | 326 @end deftypefn"), |
1 | 327 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
328 pair_type ("endswitch", |
5818 | 329 "-*- texinfo -*-\n\ |
11547 | 330 @deftypefn {Keyword} {} endswitch\n\ |
5818 | 331 Mark the end of a switch block. See @code{switch} for an example.\n\ |
332 @seealso{switch}\n\ | |
11547 | 333 @end deftypefn"), |
5122 | 334 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
335 pair_type ("endwhile", |
5818 | 336 "-*- texinfo -*-\n\ |
11547 | 337 @deftypefn {Keyword} {} endwhile\n\ |
5818 | 338 Mark the end of a while loop. See @code{while} for an example.\n\ |
339 @seealso{do, while}\n\ | |
11547 | 340 @end deftypefn"), |
1 | 341 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
342 pair_type ("for", |
5818 | 343 "-*- texinfo -*-\n\ |
11547 | 344 @deftypefn {Keyword} {} for @var{i} = @var{range}\n\ |
5818 | 345 Begin a for loop.\n\ |
10840 | 346 \n\ |
5818 | 347 @example\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
348 @group\n\ |
5818 | 349 for i = 1:10\n\ |
350 i\n\ | |
351 endfor\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
352 @end group\n\ |
5818 | 353 @end example\n\ |
354 @seealso{do, while}\n\ | |
11547 | 355 @end deftypefn"), |
1 | 356 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
357 pair_type ("function", |
5818 | 358 "-*- texinfo -*-\n\ |
11547 | 359 @deftypefn {Keyword} {} function @var{outputs} = function (@var{input}, @dots{})\n\ |
360 @deftypefnx {Keyword} {} function {} function (@var{input}, @dots{})\n\ | |
361 @deftypefnx {Keyword} {} function @var{outputs} = function\n\ | |
5818 | 362 Begin a function body with @var{outputs} as results and @var{inputs} as\n\ |
363 parameters.\n\ | |
364 @seealso{return}\n\ | |
11547 | 365 @end deftypefn"), |
1 | 366 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
367 pair_type ("global", |
5818 | 368 "-*- texinfo -*-\n\ |
11547 | 369 @deftypefn {Keyword} {} global\n\ |
5818 | 370 Declare variables to have global scope.\n\ |
10840 | 371 \n\ |
5818 | 372 @example\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
373 @group\n\ |
5818 | 374 global @var{x};\n\ |
375 if isempty (@var{x})\n\ | |
376 x = 1;\n\ | |
377 endif\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
378 @end group\n\ |
5818 | 379 @end example\n\ |
380 @seealso{persistent}\n\ | |
11547 | 381 @end deftypefn"), |
1 | 382 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
383 pair_type ("if", |
5393 | 384 "-*- texinfo -*-\n\ |
11547 | 385 @deftypefn {Keyword} {} if (@var{cond}) @dots{} endif\n\ |
386 @deftypefnx {Keyword} {} if (@var{cond}) @dots{} else @dots{} endif\n\ | |
387 @deftypefnx {Keyword} {} if (@var{cond}) @dots{} elseif (@var{cond}) @dots{} endif\n\ | |
388 @deftypefnx {Keyword} {} if (@var{cond}) @dots{} elseif (@var{cond}) @dots{} else @dots{} endif\n\ | |
5393 | 389 Begin an if block.\n\ |
10840 | 390 \n\ |
5818 | 391 @example\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
392 @group\n\ |
5818 | 393 x = 1;\n\ |
394 if (x == 1)\n\ | |
395 disp (\"one\");\n\ | |
396 elseif (x == 2)\n\ | |
397 disp (\"two\");\n\ | |
398 else\n\ | |
399 disp (\"not one or two\");\n\ | |
400 endif\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
401 @end group\n\ |
5818 | 402 @end example\n\ |
5646 | 403 @seealso{switch}\n\ |
11547 | 404 @end deftypefn"), |
1 | 405 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
406 pair_type ("otherwise", |
5818 | 407 "-*- texinfo -*-\n\ |
11547 | 408 @deftypefn {Keyword} {} otherwise\n\ |
5818 | 409 The default statement in a switch block (similar to else in an if block).\n\ |
410 @seealso{switch}\n\ | |
11547 | 411 @end deftypefn"), |
5040 | 412 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
413 pair_type ("persistent", |
5818 | 414 "-*- texinfo -*-\n\ |
11547 | 415 @deftypefn {Keyword} {} persistent @var{var}\n\ |
5818 | 416 Declare variables as persistent. A variable that has been declared\n\ |
5623 | 417 persistent within a function will retain its contents in memory between\n\ |
418 subsequent calls to the same function. The difference between persistent\n\ | |
5818 | 419 variables and global variables is that persistent variables are local in \n\ |
420 scope to a particular function and are not visible elsewhere.\n\ | |
421 @seealso{global}\n\ | |
11547 | 422 @end deftypefn"), |
4686 | 423 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
424 pair_type ("replot", |
5818 | 425 "-*- texinfo -*-\n\ |
11547 | 426 @deftypefn {Keyword} {} replot\n\ |
5818 | 427 Replot a graphic.\n\ |
428 @seealso{plot}\n\ | |
11547 | 429 @end deftypefn"), |
5040 | 430 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
431 pair_type ("return", |
5818 | 432 "-*- texinfo -*-\n\ |
11547 | 433 @deftypefn {Keyword} {} return\n\ |
5818 | 434 Return from a function.\n\ |
435 @seealso{function}\n\ | |
11547 | 436 @end deftypefn"), |
928 | 437 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
438 pair_type ("static", |
5818 | 439 "-*- texinfo -*-\n\ |
11547 | 440 @deftypefn {Keyword} {} static\n\ |
5818 | 441 This function has been deprecated in favor of persistent.\n\ |
442 @seealso{persistent}\n\ | |
11547 | 443 @end deftypefn"), |
5040 | 444 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
445 pair_type ("switch", |
5818 | 446 "-*- texinfo -*-\n\ |
11547 | 447 @deftypefn {Keyword} {} switch @var{statement}\n\ |
5818 | 448 Begin a switch block.\n\ |
10840 | 449 \n\ |
5818 | 450 @example\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
451 @group\n\ |
5818 | 452 yesno = \"yes\"\n\ |
453 \n\ | |
454 switch yesno\n\ | |
5832 | 455 case @{\"Yes\" \"yes\" \"YES\" \"y\" \"Y\"@}\n\ |
5818 | 456 value = 1;\n\ |
5832 | 457 case @{\"No\" \"no\" \"NO\" \"n\" \"N\"@}\n\ |
5818 | 458 value = 0;\n\ |
459 otherwise\n\ | |
460 error (\"invalid value\");\n\ | |
461 endswitch\n\ | |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
462 @end group\n\ |
5818 | 463 @end example\n\ |
464 @seealso{if, case, otherwise}\n\ | |
11547 | 465 @end deftypefn"), |
5040 | 466 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
467 pair_type ("try", |
5818 | 468 "-*- texinfo -*-\n\ |
11547 | 469 @deftypefn {Keyword} {} try\n\ |
5818 | 470 Begin a try-catch block.\n\ |
6138 | 471 \n\ |
472 If an error occurs within a try block, then the catch code will be run and\n\ | |
473 execution will proceed after the catch block (though it is often\n\ | |
474 recommended to use the lasterr function to re-throw the error after cleanup\n\ | |
475 is completed).\n\ | |
476 @seealso{catch,unwind_protect}\n\ | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
477 @end deftypefn"), |
1489 | 478 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
479 pair_type ("until", |
5818 | 480 "-*- texinfo -*-\n\ |
11547 | 481 @deftypefn {Keyword} {} until\n\ |
5818 | 482 End a do-until loop.\n\ |
483 @seealso{do}\n\ | |
11547 | 484 @end deftypefn"), |
5040 | 485 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
486 pair_type ("unwind_protect", |
5818 | 487 "-*- texinfo -*-\n\ |
11547 | 488 @deftypefn {Keyword} {} unwind_protect\n\ |
5818 | 489 Begin an unwind_protect block.\n\ |
6138 | 490 \n\ |
491 If an error occurs within the first part of an unwind_protect block\n\ | |
492 the commands within the unwind_protect_cleanup block are executed before\n\ | |
493 the error is thrown. If an error is not thrown, then the\n\ | |
494 unwind_protect_cleanup block is still executed (in other words, the\n\ | |
495 unwind_protect_cleanup will be run with or without an error in the\n\ | |
496 unwind_protect block).\n\ | |
497 @seealso{unwind_protect_cleanup,try}\n\ | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
498 @end deftypefn"), |
928 | 499 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
500 pair_type ("unwind_protect_cleanup", |
5818 | 501 "-*- texinfo -*-\n\ |
11547 | 502 @deftypefn {Keyword} {} unwind_protect_cleanup\n\ |
5818 | 503 Begin the cleanup section of an unwind_protect block.\n\ |
504 @seealso{unwind_protect}\n\ | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
505 @end deftypefn"), |
1 | 506 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
507 pair_type ("varargin", |
5818 | 508 "-*- texinfo -*-\n\ |
11547 | 509 @deftypefn {Keyword} {} varargin\n\ |
5818 | 510 Pass an arbitrary number of arguments into a function.\n\ |
511 @seealso{varargout, nargin, nargout}\n\ | |
11547 | 512 @end deftypefn"), |
5040 | 513 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
514 pair_type ("varargout", |
5818 | 515 "-*- texinfo -*-\n\ |
11547 | 516 @deftypefn {Keyword} {} varargout\n\ |
5818 | 517 Pass an arbitrary number of arguments out of a function.\n\ |
518 @seealso{varargin, nargin, nargout}\n\ | |
11547 | 519 @end deftypefn"), |
5040 | 520 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
521 pair_type ("while", |
5818 | 522 "-*- texinfo -*-\n\ |
11547 | 523 @deftypefn {Keyword} {} while\n\ |
5818 | 524 Begin a while loop.\n\ |
525 @seealso{do}\n\ | |
11547 | 526 @end deftypefn"), |
1 | 527 }; |
528 | |
581 | 529 // Return a copy of the operator or keyword names. |
3016 | 530 static string_vector |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
531 names (const map_type& lst) |
1 | 532 { |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
533 string_vector retval (lst.size ()); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
534 int j = 0; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
535 for (map_iter iter = lst.begin (); iter != lst.end (); iter ++) |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
536 retval [j++] = iter->first; |
1755 | 537 return retval; |
1 | 538 } |
539 | |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
540 const static map_type operators_map (operators, operators + size (operators)); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
541 const static map_type keywords_map (keywords, keywords + size (keywords)); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
542 const static string_vector keyword_names = names (keywords_map); |
1 | 543 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
544 // FIXME -- It's not likely that this does the right thing now. |
3016 | 545 |
546 string_vector | |
547 make_name_list (void) | |
548 { | |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
549 const int key_len = keyword_names.length (); |
3016 | 550 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
551 const string_vector bif = symbol_table::built_in_function_names (); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
552 const int bif_len = bif.length (); |
4009 | 553 |
10500
8f27f368aba2
fix generating names for TAB completion
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
554 const string_vector lcl = symbol_table::variable_names (); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
555 const int lcl_len = lcl.length (); |
3016 | 556 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
557 const string_vector ffl = load_path::fcn_names (); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
558 const int ffl_len = ffl.length (); |
3016 | 559 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
560 const string_vector afl = autoloaded_functions (); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
561 const int afl_len = afl.length (); |
5592 | 562 |
10500
8f27f368aba2
fix generating names for TAB completion
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
563 const int total_len = key_len + bif_len + lcl_len + ffl_len + afl_len; |
3016 | 564 |
565 string_vector list (total_len); | |
566 | |
567 // Put all the symbols in one big list. | |
568 | |
569 int j = 0; | |
570 int i = 0; | |
571 for (i = 0; i < key_len; i++) | |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
572 list[j++] = keyword_names[i]; |
3016 | 573 |
7336 | 574 for (i = 0; i < bif_len; i++) |
575 list[j++] = bif[i]; | |
4009 | 576 |
3016 | 577 for (i = 0; i < lcl_len; i++) |
578 list[j++] = lcl[i]; | |
579 | |
580 for (i = 0; i < ffl_len; i++) | |
581 list[j++] = ffl[i]; | |
582 | |
5592 | 583 for (i = 0; i < afl_len; i++) |
584 list[j++] = afl[i]; | |
585 | |
3016 | 586 return list; |
587 } | |
588 | |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
589 static bool |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
590 looks_like_html (const std::string& msg) |
3014 | 591 { |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
592 const size_t p1 = msg.find ('\n'); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
593 std::string t = msg.substr (0, p1); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
594 const size_t p2 = t.find ("<html"); // FIXME: this comparison should be case-insensitive |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
595 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
596 return (p2 != std::string::npos); |
2470 | 597 } |
3014 | 598 |
599 static bool | |
3523 | 600 looks_like_texinfo (const std::string& msg, size_t& p1) |
3295 | 601 { |
602 p1 = msg.find ('\n'); | |
603 | |
3523 | 604 std::string t = msg.substr (0, p1); |
3295 | 605 |
8021 | 606 if (p1 == std::string::npos) |
3295 | 607 p1 = 0; |
608 | |
609 size_t p2 = t.find ("-*- texinfo -*-"); | |
610 | |
8021 | 611 return (p2 != std::string::npos); |
3295 | 612 } |
613 | |
3355 | 614 static bool |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
615 raw_help_from_symbol_table (const std::string& nm, std::string& h, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
616 std::string& w, bool& symbol_found) |
3355 | 617 { |
618 bool retval = false; | |
619 | |
7336 | 620 octave_value val = symbol_table::find_function (nm); |
3355 | 621 |
7336 | 622 if (val.is_defined ()) |
3355 | 623 { |
7336 | 624 octave_function *fcn = val.function_value (); |
625 | |
626 if (fcn) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
627 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
628 symbol_found = true; |
5399 | 629 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
630 h = fcn->doc_string (); |
7336 | 631 |
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
|
632 retval = true; |
52956d669506
Display sensible error message when the help text of an undocumented function is requested
Soren Hauberg <hauberg@gmail.com>
parents:
8630
diff
changeset
|
633 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
634 w = fcn->fcn_file_name (); |
6243 | 635 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
636 if (w.empty ()) |
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
|
637 w = fcn->is_user_function () |
52956d669506
Display sensible error message when the help text of an undocumented function is requested
Soren Hauberg <hauberg@gmail.com>
parents:
8630
diff
changeset
|
638 ? "command-line function" : "built-in function"; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
639 } |
6243 | 640 } |
3355 | 641 |
6243 | 642 return retval; |
643 } | |
644 | |
645 static bool | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
646 raw_help_from_file (const std::string& nm, std::string& h, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
647 std::string& file, bool& symbol_found) |
6243 | 648 { |
649 bool retval = false; | |
650 | |
8672
2a49c32d4322
allow help to work with files containing only comments
John W. Eaton <jwe@octave.org>
parents:
8631
diff
changeset
|
651 // FIXME -- this is a bit of a kluge... |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9806
diff
changeset
|
652 unwind_protect frame; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
9806
diff
changeset
|
653 frame.protect_var (reading_script_file); |
8672
2a49c32d4322
allow help to work with files containing only comments
John W. Eaton <jwe@octave.org>
parents:
8631
diff
changeset
|
654 reading_script_file = true; |
2a49c32d4322
allow help to work with files containing only comments
John W. Eaton <jwe@octave.org>
parents:
8631
diff
changeset
|
655 |
6243 | 656 h = get_help_from_file (nm, symbol_found, file); |
657 | |
658 if (h.length () > 0) | |
659 retval = true; | |
660 | |
661 return retval; | |
662 } | |
663 | |
664 static bool | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
665 raw_help_from_map (const std::string& nm, std::string& h, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
666 const map_type& map, bool& symbol_found) |
3355 | 667 { |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
668 map_iter idx = map.find (nm); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
669 symbol_found = (idx != map.end ()); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
670 h = (symbol_found) ? idx->second : ""; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
671 return symbol_found; |
3355 | 672 } |
673 | |
6243 | 674 std::string |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
675 raw_help (const std::string& nm, bool& symbol_found) |
6243 | 676 { |
677 std::string h; | |
678 std::string w; | |
679 std::string f; | |
680 | |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
681 (raw_help_from_symbol_table (nm, h, w, symbol_found) |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
682 || raw_help_from_file (nm, h, f, symbol_found) |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
683 || raw_help_from_map (nm, h, operators_map, symbol_found) |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
684 || raw_help_from_map (nm, h, keywords_map, symbol_found)); |
6243 | 685 |
686 return h; | |
687 } | |
688 | |
1140 | 689 static void |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
690 do_get_help_text (const std::string& name, std::string& text, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
691 std::string& format) |
1140 | 692 { |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
693 bool symbol_found = false; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
694 text = raw_help (name, symbol_found); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
695 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
696 format = "Not found"; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
697 if (symbol_found) |
1140 | 698 { |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
699 size_t idx = -1; |
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
|
700 if (text.empty ()) |
52956d669506
Display sensible error message when the help text of an undocumented function is requested
Soren Hauberg <hauberg@gmail.com>
parents:
8630
diff
changeset
|
701 { |
52956d669506
Display sensible error message when the help text of an undocumented function is requested
Soren Hauberg <hauberg@gmail.com>
parents:
8630
diff
changeset
|
702 format = "Not documented"; |
52956d669506
Display sensible error message when the help text of an undocumented function is requested
Soren Hauberg <hauberg@gmail.com>
parents:
8630
diff
changeset
|
703 } |
52956d669506
Display sensible error message when the help text of an undocumented function is requested
Soren Hauberg <hauberg@gmail.com>
parents:
8630
diff
changeset
|
704 else if (looks_like_texinfo (text, idx)) |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
705 { |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
706 format = "texinfo"; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
707 text.erase (0, idx); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
708 } |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
709 else if (looks_like_html (text)) |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
710 { |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
711 format = "html"; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
712 } |
5399 | 713 else |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
714 { |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
715 format = "plain text"; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
716 } |
1140 | 717 } |
718 } | |
719 | |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
720 DEFUN (get_help_text, args, , "-*- texinfo -*-\n\ |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
721 @deftypefn {Loadable Function} {[@var{text}, @var{format}] =} get_help_text (@var{name})\n\ |
12519
91ccd08fe80c
Add gen_doc_cache, get_help_text, get_help_text_from_file, get_first_help_sentence to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
722 Return the raw help text of function @var{name}.\n\ |
3168 | 723 \n\ |
12519
91ccd08fe80c
Add gen_doc_cache, get_help_text, get_help_text_from_file, get_first_help_sentence to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
724 The raw help text is returned in @var{text} and the format in @var{format}\n\ |
91ccd08fe80c
Add gen_doc_cache, get_help_text, get_help_text_from_file, get_first_help_sentence to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
725 The format is a string which is one of @t{\"texinfo\"}, @t{\"html\"}, or\n\ |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
726 @t{\"plain text\"}.\n\ |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
727 @end deftypefn") |
529 | 728 { |
2086 | 729 octave_value_list retval; |
529 | 730 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
731 if (args.length () == 1) |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
732 { |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
733 const std::string name = args (0).string_value (); |
1755 | 734 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
735 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
736 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
737 std::string text; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
738 std::string format; |
529 | 739 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
740 do_get_help_text (name, text, format); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
741 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
742 retval(1) = format; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
743 retval(0) = text; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
744 } |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
745 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
746 error ("get_help_text: invalid input"); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
747 } |
529 | 748 else |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
749 print_usage (); |
529 | 750 |
751 return retval; | |
752 } | |
753 | |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
754 static void |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
755 do_get_help_text_from_file (const std::string& fname, std::string& text, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
756 std::string& format) |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
757 { |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
758 bool symbol_found = false; |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
759 |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
760 std::string f; |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
761 |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
762 raw_help_from_file (fname, text, f, symbol_found); |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
763 |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
764 format = "Not found"; |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
765 if (symbol_found) |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
766 { |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
767 size_t idx = -1; |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
768 if (text.empty ()) |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
769 { |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
770 format = "Not documented"; |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
771 } |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
772 else if (looks_like_texinfo (text, idx)) |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
773 { |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
774 format = "texinfo"; |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
775 text.erase (0, idx); |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
776 } |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
777 else if (looks_like_html (text)) |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
778 { |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
779 format = "html"; |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
780 } |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
781 else |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
782 { |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
783 format = "plain text"; |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
784 } |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
785 } |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
786 } |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
787 |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
788 DEFUN (get_help_text_from_file, args, , |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
789 "-*- texinfo -*-\n\ |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
790 @deftypefn {Loadable Function} {[@var{text}, @var{format}] =} get_help_text_from_file (@var{fname})\n\ |
12519
91ccd08fe80c
Add gen_doc_cache, get_help_text, get_help_text_from_file, get_first_help_sentence to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
791 Return the raw help text from the file @var{fname}.\n\ |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
792 \n\ |
12519
91ccd08fe80c
Add gen_doc_cache, get_help_text, get_help_text_from_file, get_first_help_sentence to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
793 The raw help text is returned in @var{text} and the format in @var{format}\n\ |
91ccd08fe80c
Add gen_doc_cache, get_help_text, get_help_text_from_file, get_first_help_sentence to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12483
diff
changeset
|
794 The format is a string which is one of @t{\"texinfo\"}, @t{\"html\"}, or\n\ |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
795 @t{\"plain text\"}.\n\ |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
796 @end deftypefn") |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
797 { |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
798 octave_value_list retval; |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
799 |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
800 if (args.length () == 1) |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
801 { |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
802 const std::string fname = args(0).string_value (); |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
803 |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
804 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
805 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
806 std::string text; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
807 std::string format; |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
808 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
809 do_get_help_text_from_file (fname, text, format); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
810 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
811 retval(1) = format; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
812 retval(0) = text; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
813 } |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
814 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
815 error ("get_help_text_from_file: invalid input"); |
9806
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
816 } |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
817 else |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
818 print_usage (); |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
819 |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
820 return retval; |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
821 } |
8e345f2fe4d6
improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents:
9416
diff
changeset
|
822 |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
823 // Return a cell array of strings containing the names of all |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
824 // operators. |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
825 |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
826 DEFUN (__operators__, , , |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
827 "-*- texinfo -*-\n\ |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
828 @deftypefn {Function File} __operators__ ()\n\ |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
829 Undocumented internal function.\n\ |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
830 @end deftypefn") |
3355 | 831 { |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
832 return octave_value (Cell (names (operators_map))); |
3355 | 833 } |
834 | |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
835 // Return a cell array of strings containing the names of all |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
836 // keywords. |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
837 |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
838 DEFUN (__keywords__, , , |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
839 "-*- texinfo -*-\n\ |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
840 @deftypefn {Function File} __keywords__ ()\n\ |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
841 Undocumented internal function.\n\ |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
842 @end deftypefn") |
581 | 843 { |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
844 return octave_value (Cell (names (keywords_map))); |
581 | 845 } |
846 | |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
847 // Return a cell array of strings containing the names of all builtin |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
848 // functions. |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
849 |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
850 DEFUN (__builtins__, , , |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
851 "-*- texinfo -*-\n\ |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
852 @deftypefn {Function File} __builtins__ ()\n\ |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
853 Undocumented internal function.\n\ |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
854 @end deftypefn") |
3355 | 855 { |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
856 const string_vector bif = symbol_table::built_in_function_names (); |
3355 | 857 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
858 return octave_value (Cell (bif)); |
3355 | 859 } |
860 | |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
861 static std::string |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
862 do_which (const std::string& name, std::string& type) |
3355 | 863 { |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
864 std::string file; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
865 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
866 type = std::string (); |
3355 | 867 |
7336 | 868 octave_value val = symbol_table::find_function (name); |
869 | |
9416
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
870 if (name.find_first_of ('.') == std::string::npos) |
3355 | 871 { |
9416
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
872 if (val.is_defined ()) |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
873 { |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
874 octave_function *fcn = val.function_value (); |
7336 | 875 |
9416
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
876 if (fcn) |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
877 { |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
878 file = fcn->fcn_file_name (); |
3355 | 879 |
9416
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
880 if (file.empty ()) |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
881 { |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
882 if (fcn->is_user_function ()) |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
883 type = "command-line function"; |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
884 else |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
885 type = "built-in function"; |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
886 } |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
887 else |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
888 type = val.is_user_script () |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
889 ? std::string ("script") : std::string ("function"); |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
890 } |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
891 } |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
892 else |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
893 { |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
894 // We might find a file that contains only a doc string. |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
895 |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
896 file = load_path::find_fcn_file (name); |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
897 } |
7336 | 898 } |
8672
2a49c32d4322
allow help to work with files containing only comments
John W. Eaton <jwe@octave.org>
parents:
8631
diff
changeset
|
899 else |
2a49c32d4322
allow help to work with files containing only comments
John W. Eaton <jwe@octave.org>
parents:
8631
diff
changeset
|
900 { |
9416
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
901 // File query. |
8672
2a49c32d4322
allow help to work with files containing only comments
John W. Eaton <jwe@octave.org>
parents:
8631
diff
changeset
|
902 |
9416
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
903 // For compatibility: "file." queries "file". |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
904 if (name.size () > 1 && name[name.size () - 1] == '.') |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
905 file = load_path::find_file (name.substr (0, name.size () - 1)); |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
906 else |
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
907 file = load_path::find_file (name); |
8672
2a49c32d4322
allow help to work with files containing only comments
John W. Eaton <jwe@octave.org>
parents:
8631
diff
changeset
|
908 } |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
909 |
9416
2cc47338e427
allow which look for files on path
Jaroslav Hajek <highegg@gmail.com>
parents:
9377
diff
changeset
|
910 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
911 return file; |
3355 | 912 } |
913 | |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
914 std::string |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
915 do_which (const std::string& name) |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
916 { |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
917 std::string retval; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
918 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
919 std::string type; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
920 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
921 retval = do_which (name, type); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
922 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
923 return retval; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
924 } |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
925 |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
926 DEFUN (__which__, args, , |
3361 | 927 "-*- texinfo -*-\n\ |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
928 @deftypefn {Built-in Function} {} __which__ (@var{name}, @dots{})\n\ |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
929 Undocumented internal function.\n\ |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
930 @end deftypefn") |
581 | 931 { |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
932 octave_value retval; |
581 | 933 |
1968 | 934 string_vector argv = args.make_argv ("which"); |
1755 | 935 |
3355 | 936 if (! error_state) |
937 { | |
938 int argc = argv.length (); | |
581 | 939 |
3355 | 940 if (argc > 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
941 { |
11059
4ffa19147604
replace Octave_map->octave_scalar_map in help.cc and load-save.cc
Jaroslav Hajek <highegg@gmail.com>
parents:
10840
diff
changeset
|
942 octave_map m (dim_vector (1, argc-1)); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
943 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
944 Cell names (1, argc-1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
945 Cell files (1, argc-1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
946 Cell types (1, argc-1); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
947 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
948 for (int i = 1; i < argc; i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
949 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
950 std::string name = argv[i]; |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
951 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
952 std::string type; |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
953 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
954 std::string file = do_which (name, type); |
3141 | 955 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
956 names(i-1) = name; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
957 files(i-1) = file; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
958 types(i-1) = type; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
959 } |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
960 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
961 m.assign ("name", names); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
962 m.assign ("file", files); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
963 m.assign ("type", types); |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
964 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
965 retval = m; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
966 } |
3355 | 967 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
968 print_usage (); |
581 | 969 } |
970 | |
971 return retval; | |
972 } | |
973 | |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
974 // FIXME -- Are we sure this function always does the right thing? |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
975 inline bool |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
976 file_is_in_dir (const std::string filename, const std::string dir) |
5447 | 977 { |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
978 if (filename.find (dir) == 0) |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
979 { |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
980 const int dir_len = dir.size (); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
981 const int filename_len = filename.size (); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
982 const int max_allowed_seps = file_ops::is_dir_sep (dir [dir_len-1]) ? 0 : 1; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
983 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
984 int num_seps = 0; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
985 for (int i = dir_len; i < filename_len; i++) |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
986 if (file_ops::is_dir_sep (filename [i])) |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
987 num_seps ++; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
988 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
989 return (num_seps <= max_allowed_seps); |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
990 } |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
991 else |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
992 return false; |
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
993 } |
5447 | 994 |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
995 // Return a cell array of strings containing the names of all |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
996 // functions available in DIRECTORY. If no directory is given, search |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
997 // the current path. |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
998 |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
999 DEFUN (__list_functions__, args, , |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
1000 "-*- texinfo -*-\n\ |
10840 | 1001 @deftypefn {Function File} {@var{retval} =} __list_functions__ ()\n\ |
1002 @deftypefnx {Function File} {@var{retval} =} __list_functions__ (@var{directory})\n\ | |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
1003 Undocumented internal function.\n\ |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8672
diff
changeset
|
1004 @end deftypefn") |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
1005 { |
8863
34a821854961
pkg.m (generate_lookfor_cache): generate a DOC file for each directory
Jason Riedy <jason@acm.org>
parents:
8861
diff
changeset
|
1006 octave_value retval; |
5447 | 1007 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
1008 // Get list of functions |
8863
34a821854961
pkg.m (generate_lookfor_cache): generate a DOC file for each directory
Jason Riedy <jason@acm.org>
parents:
8861
diff
changeset
|
1009 string_vector ffl = load_path::fcn_names (); |
34a821854961
pkg.m (generate_lookfor_cache): generate a DOC file for each directory
Jason Riedy <jason@acm.org>
parents:
8861
diff
changeset
|
1010 string_vector afl = autoloaded_functions (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
1011 |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
1012 if (args.length () == 0) |
8863
34a821854961
pkg.m (generate_lookfor_cache): generate a DOC file for each directory
Jason Riedy <jason@acm.org>
parents:
8861
diff
changeset
|
1013 retval = Cell (ffl.append (afl)); |
5447 | 1014 else |
1015 { | |
8575
f134925a1cfa
m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents:
8503
diff
changeset
|
1016 std::string dir = args (0).string_value (); |
8863
34a821854961
pkg.m (generate_lookfor_cache): generate a DOC file for each directory
Jason Riedy <jason@acm.org>
parents:
8861
diff
changeset
|
1017 |
34a821854961
pkg.m (generate_lookfor_cache): generate a DOC file for each directory
Jason Riedy <jason@acm.org>
parents:
8861
diff
changeset
|
1018 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
1019 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
1020 string_vector fl = load_path::files (dir, true); |
8863
34a821854961
pkg.m (generate_lookfor_cache): generate a DOC file for each directory
Jason Riedy <jason@acm.org>
parents:
8861
diff
changeset
|
1021 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
1022 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
1023 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
1024 // Return a sorted list with unique entries (in case of |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
1025 // .m and .oct versions of the same function in a given |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
1026 // directory, for example). |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
1027 fl.sort (true); |
9261
95445f9f5976
omit file extensions from __list_functions__ output
John W. Eaton <jwe@octave.org>
parents:
9133
diff
changeset
|
1028 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
1029 retval = Cell (fl); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
1030 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
1031 } |
5447 | 1032 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
11586
diff
changeset
|
1033 error ("__list_functions__: DIRECTORY argument must be a string"); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
1034 } |
5447 | 1035 |
1036 return retval; | |
1037 } | |
1038 | |
8861 | 1039 DEFUN (doc_cache_file, args, nargout, |
1040 "-*- texinfo -*-\n\ | |
10840 | 1041 @deftypefn {Built-in Function} {@var{val} =} doc_cache_file ()\n\ |
8861 | 1042 @deftypefnx {Built-in Function} {@var{old_val} =} doc_cache_file (@var{new_val})\n\ |
1043 Query or set the internal variable that specifies the name of the\n\ | |
9133
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1044 Octave documentation cache file. A cache file significantly improves\n\ |
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1045 the performance of the @code{lookfor} command. The default value is \n\ |
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1046 @file{@var{octave-home}/share/octave/@var{version}/etc/doc-cache},\n\ |
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1047 in which @var{octave-home} is the root directory of the Octave installation,\n\ |
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1048 and @var{version} is the Octave version number.\n\ |
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1049 The default value may be overridden by the environment variable\n\ |
10840 | 1050 @w{@env{OCTAVE_DOC_CACHE_FILE}}, or the command line argument\n\ |
9133
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1051 @samp{--doc-cache-file NAME}.\n\ |
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1052 @seealso{lookfor, info_program, doc, help, makeinfo_program}\n\ |
8861 | 1053 @end deftypefn") |
1054 { | |
1055 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (doc_cache_file); | |
1056 } | |
1057 | |
5794 | 1058 DEFUN (info_file, args, nargout, |
1059 "-*- texinfo -*-\n\ | |
10840 | 1060 @deftypefn {Built-in Function} {@var{val} =} info_file ()\n\ |
5794 | 1061 @deftypefnx {Built-in Function} {@var{old_val} =} info_file (@var{new_val})\n\ |
1062 Query or set the internal variable that specifies the name of the\n\ | |
1063 Octave info file. The default value is\n\ | |
9133
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1064 @file{@var{octave-home}/info/octave.info}, in\n\ |
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1065 which @var{octave-home} is the root directory of the Octave installation.\n\ |
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1066 The default value may be overridden by the environment variable\n\ |
10840 | 1067 @w{@env{OCTAVE_INFO_FILE}}, or the command line argument\n\ |
9133
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1068 @samp{--info-file NAME}.\n\ |
5794 | 1069 @seealso{info_program, doc, help, makeinfo_program}\n\ |
1070 @end deftypefn") | |
2202 | 1071 { |
5794 | 1072 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (info_file); |
2202 | 1073 } |
1074 | |
5794 | 1075 DEFUN (info_program, args, nargout, |
1076 "-*- texinfo -*-\n\ | |
10840 | 1077 @deftypefn {Built-in Function} {@var{val} =} info_program ()\n\ |
5794 | 1078 @deftypefnx {Built-in Function} {@var{old_val} =} info_program (@var{new_val})\n\ |
1079 Query or set the internal variable that specifies the name of the\n\ | |
7096 | 1080 info program to run. The default value is\n\ |
9133
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1081 @file{@var{octave-home}/libexec/octave/@var{version}/exec/@var{arch}/info}\n\ |
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1082 in which @var{octave-home} is the root directory of the Octave installation,\n\ |
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1083 @var{version} is the Octave version number, and @var{arch}\n\ |
3686 | 1084 is the system type (for example, @code{i686-pc-linux-gnu}). The\n\ |
9133
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1085 default value may be overridden by the environment variable\n\ |
10840 | 1086 @w{@env{OCTAVE_INFO_PROGRAM}}, or the command line argument\n\ |
9133
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1087 @samp{--info-program NAME}.\n\ |
5794 | 1088 @seealso{info_file, doc, help, makeinfo_program}\n\ |
1089 @end deftypefn") | |
1090 { | |
1091 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (info_program); | |
1092 } | |
3686 | 1093 |
5794 | 1094 DEFUN (makeinfo_program, args, nargout, |
1095 "-*- texinfo -*-\n\ | |
10840 | 1096 @deftypefn {Built-in Function} {@var{val} =} makeinfo_program ()\n\ |
5794 | 1097 @deftypefnx {Built-in Function} {@var{old_val} =} makeinfo_program (@var{new_val})\n\ |
1098 Query or set the internal variable that specifies the name of the\n\ | |
9133
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1099 program that Octave runs to format help text containing\n\ |
c0cef1436788
Update help text for sections 2.2 and 2.3 of basics.txi
Rik <rdrider0-list@yahoo.com>
parents:
9064
diff
changeset
|
1100 Texinfo markup commands. The default value is @code{makeinfo}.\n\ |
5794 | 1101 @seealso{info_file, info_program, doc, help}\n\ |
1102 @end deftypefn") | |
1103 { | |
1104 return SET_NONEMPTY_INTERNAL_STRING_VARIABLE (makeinfo_program); | |
1105 } | |
2202 | 1106 |
5794 | 1107 DEFUN (suppress_verbose_help_message, args, nargout, |
1108 "-*- texinfo -*-\n\ | |
10840 | 1109 @deftypefn {Built-in Function} {@var{val} =} suppress_verbose_help_message ()\n\ |
5794 | 1110 @deftypefnx {Built-in Function} {@var{old_val} =} suppress_verbose_help_message (@var{new_val})\n\ |
7001 | 1111 Query or set the internal variable that controls whether Octave\n\ |
5794 | 1112 will add additional help information to the end of the output from\n\ |
3332 | 1113 the @code{help} command and usage messages for built-in commands.\n\ |
5794 | 1114 @end deftypefn") |
1115 { | |
1116 return SET_INTERNAL_VARIABLE (suppress_verbose_help_message); | |
2189 | 1117 } |