annotate libinterp/corefcn/help.cc @ 27919:1891570abac8

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2020.
author John W. Eaton <jwe@octave.org>
date Mon, 06 Jan 2020 22:29:51 -0500
parents b442ec6dda5c
children bd51beb6205e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
1 /*
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
2
27919
1891570abac8 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27918
diff changeset
3 Copyright (C) 1993-2020 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27745
diff changeset
4
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27745
diff changeset
5 See the file COPYRIGHT.md in the top-level directory of this distribution
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27745
diff changeset
6 or <https://octave.org/COPYRIGHT.html/>.
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27745
diff changeset
7
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
8
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
9 This file is part of Octave.
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
10
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24361
diff changeset
11 Octave is free software: you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22556
diff changeset
12 under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24361
diff changeset
13 the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22556
diff changeset
14 (at your option) any later version.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
15
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22556
diff changeset
16 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22556
diff changeset
17 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22556
diff changeset
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22556
diff changeset
19 GNU General Public License for more details.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
20
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
21 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 7001
diff changeset
22 along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24361
diff changeset
23 <https://www.gnu.org/licenses/>.
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
24
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
25 */
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
26
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
27 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21200
diff changeset
28 # include "config.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
29 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
30
1343
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
31 #include <cstdlib>
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
32 #include <cstring>
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
33
5769
2b9a5ce46678 [project @ 2006-04-18 15:57:06 by jwe]
jwe
parents: 5768
diff changeset
34 #include <algorithm>
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
35 #include <fstream>
25438
cb1606f78f6b prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents: 25395
diff changeset
36 #include <istream>
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
37 #include <map>
5765
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5738
diff changeset
38 #include <sstream>
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1742
diff changeset
39 #include <string>
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1742
diff changeset
40
3295
35a6d027772c [project @ 1999-10-19 10:13:02 by jwe]
jwe
parents: 3259
diff changeset
41 #include "cmd-edit.h"
35a6d027772c [project @ 1999-10-19 10:13:02 by jwe]
jwe
parents: 3259
diff changeset
42 #include "file-ops.h"
6253
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 6243
diff changeset
43 #include "file-stat.h"
25548
d6050ba12c0c Call get_ASCII_filename for std::ifstream (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents: 25460
diff changeset
44 #include "lo-sysdep.h"
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2900
diff changeset
45 #include "oct-env.h"
19269
65554f5847ac don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents: 19152
diff changeset
46 #include "oct-locbuf.h"
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1742
diff changeset
47 #include "str-vec.h"
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1742
diff changeset
48
23065
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
49 #include "Cell.h"
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
50 #include "builtin-defun-decls.h"
25460
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
51 #include "defaults.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
52 #include "defun.h"
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
53 #include "error.h"
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 21017
diff changeset
54 #include "errwarn.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
55 #include "help.h"
2177
0bddc913621b [project @ 1996-05-13 16:36:11 by jwe]
jwe
parents: 2124
diff changeset
56 #include "input.h"
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
57 #include "interpreter-private.h"
23065
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
58 #include "interpreter.h"
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents: 5823
diff changeset
59 #include "load-path.h"
23065
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
60 #include "ov-fcn-handle.h"
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
61 #include "ov-usr-fcn.h"
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 20939
diff changeset
62 #include "ovl.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
63 #include "pager.h"
3018
5708b8bb4f06 [project @ 1997-06-03 21:48:05 by jwe]
jwe
parents: 3016
diff changeset
64 #include "parse.h"
1466
2f85a175308f [project @ 1995-09-22 07:48:59 by jwe]
jwe
parents: 1443
diff changeset
65 #include "pathsearch.h"
3295
35a6d027772c [project @ 1999-10-19 10:13:02 by jwe]
jwe
parents: 3259
diff changeset
66 #include "procstream.h"
23065
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
67 #include "quit.h"
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 389
diff changeset
68 #include "sighandlers.h"
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 389
diff changeset
69 #include "symtab.h"
8672
2a49c32d4322 allow help to work with files containing only comments
John W. Eaton <jwe@octave.org>
parents: 8631
diff changeset
70 #include "unwind-prot.h"
242
742c4795aea9 [project @ 1993-11-30 21:26:43 by jwe]
jwe
parents: 240
diff changeset
71 #include "utils.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
72 #include "variables.h"
3301
02866242d3ae [project @ 1999-10-20 04:10:46 by jwe]
jwe
parents: 3296
diff changeset
73 #include "version.h"
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 389
diff changeset
74
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
75 #include "default-defs.h"
2189
d01936305d99 [project @ 1996-05-14 03:31:57 by jwe]
jwe
parents: 2177
diff changeset
76
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
77 namespace octave
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
78 {
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
79 const static char * const operators[] =
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
80 {
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
81 "!",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
82 "~",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
83 "!=",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
84 "~=",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
85 R"(")",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
86 "#",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
87 "%",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
88 "#{",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
89 "%{",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
90 "#}",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
91 "%}",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
92 "...",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
93 "&",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
94 "&&",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
95 "'",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
96 "(",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
97 ")",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
98 "*",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
99 "**",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
100 "^",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
101 "+",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
102 "++",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
103 ",",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
104 "-",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
105 "--",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
106 ".'",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
107 ".*",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
108 ".**",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
109 ".^",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
110 "./",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
111 "/",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
112 R"(.\)",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
113 R"(\)",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
114 ":",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
115 ";",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
116 "<",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
117 "<=",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
118 "=",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
119 "==",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
120 ">",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
121 ">=",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
122 "[",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
123 "]",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
124 "|",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
125 "||",
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
126 nullptr
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
127 };
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
128
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
129 const static string_vector operator_names (operators);
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
130
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
131 static bool
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
132 looks_like_html (const std::string& msg)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
133 {
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
134 const size_t p1 = msg.find ('\n');
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
135 std::string t = msg.substr (0, p1);
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
136 // FIXME: this comparison should be case-insensitive
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
137 const size_t p2 = t.find ("<html");
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
138
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
139 return (p2 != std::string::npos);
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
140 }
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
141
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
142 static bool
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
143 looks_like_texinfo (const std::string& msg, size_t& p1)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
144 {
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
145 p1 = msg.find ('\n');
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
146
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
147 std::string t = msg.substr (0, p1);
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
148
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
149 if (p1 == std::string::npos)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
150 p1 = 0;
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
151
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
152 size_t p2 = t.find ("-*- texinfo -*-");
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
153
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
154 return (p2 != std::string::npos);
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
155 }
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
156
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
157 octave_value
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
158 help_system::built_in_docstrings_file (const octave_value_list& args,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
159 int nargout)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
160 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
161 return set_internal_variable (m_built_in_docstrings_file, args, nargout,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
162 "built_in_docstrings_file", false);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
163 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
164
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
165 octave_value
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
166 help_system::doc_cache_file (const octave_value_list& args, int nargout)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
167 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
168 return set_internal_variable (m_doc_cache_file, args, nargout,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
169 "doc_cache_file", false);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
170 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
171
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
172 octave_value
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
173 help_system::info_file (const octave_value_list& args, int nargout)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
174 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
175 return set_internal_variable (m_info_file, args, nargout,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
176 "info_file", false);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
177 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
178
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
179 octave_value
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
180 help_system::info_program (const octave_value_list& args, int nargout)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
181 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
182 return set_internal_variable (m_info_program, args, nargout,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
183 "info_program", false);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
184 }
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
185
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
186 octave_value
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
187 help_system::makeinfo_program (const octave_value_list& args, int nargout)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
188 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
189 return set_internal_variable (m_makeinfo_program, args, nargout,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
190 "makeinfo_program", false);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
191 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
192
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
193 octave_value
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
194 help_system::suppress_verbose_help_message (const octave_value_list& args,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
195 int nargout)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
196 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
197 return set_internal_variable (m_suppress_verbose_help_message, args,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
198 nargout, "suppress_verbose_help_message");
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
199 }
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
200
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
201 octave_value
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
202 help_system::texi_macros_file (const octave_value_list& args, int nargout)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
203 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
204 return set_internal_variable (m_texi_macros_file, args, nargout,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
205 "texi_macros_file", false);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
206 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
207
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
208 std::string
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
209 help_system::raw_help (const std::string& nm, bool& symbol_found) const
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
210 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
211 std::string h;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
212 std::string w;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
213 std::string f;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
214
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
215 bool found;
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
216
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
217 found = raw_help_from_symbol_table (nm, h, w, symbol_found);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
218
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
219 if (! found)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
220 found = raw_help_from_file (nm, h, f, symbol_found);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
221
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
222 bool external_doc = h.compare (0, 12, "external-doc") == 0;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
223
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
224 if (! found || external_doc)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
225 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
226 std::string tmp_nm = nm;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
227
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
228 if (external_doc && h.length () > 12 && h[12] == ':')
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
229 tmp_nm = h.substr (13);
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
230
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
231 raw_help_from_docstrings_file (tmp_nm, h, symbol_found);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
232 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
233
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
234 return h;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
235 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
236
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
237 std::string help_system::which (const std::string& name,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
238 std::string& type) const
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
239 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
240 std::string file;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
241
26594
088b8a2dcb06 use @CLASS name when searching for @CLASS/METHOD (bug #55501)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
242 if (name.empty ())
088b8a2dcb06 use @CLASS name when searching for @CLASS/METHOD (bug #55501)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
243 return file;
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
244
26594
088b8a2dcb06 use @CLASS name when searching for @CLASS/METHOD (bug #55501)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
245 type = "";
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
246
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
247 if (name.find_first_of ('.') == std::string::npos)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
248 {
26594
088b8a2dcb06 use @CLASS name when searching for @CLASS/METHOD (bug #55501)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
249 symbol_table& symtab = m_interpreter.get_symbol_table ();
088b8a2dcb06 use @CLASS name when searching for @CLASS/METHOD (bug #55501)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
250
088b8a2dcb06 use @CLASS name when searching for @CLASS/METHOD (bug #55501)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
251 octave_value val = symtab.find_function (name);
088b8a2dcb06 use @CLASS name when searching for @CLASS/METHOD (bug #55501)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
252
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
253 if (val.is_defined ())
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
254 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
255 octave_function *fcn = val.function_value ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
256
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
257 if (fcn)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
258 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
259 file = fcn->fcn_file_name ();
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
260
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
261 if (file.empty ())
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
262 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
263 if (fcn->is_user_function ())
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
264 type = "command-line function";
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
265 else
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
266 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
267 file = fcn->src_file_name ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
268 type = "built-in function";
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
269 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
270 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
271 else
23829
01899bdd2a3a Eliminate unnecessary std::string ("...") constructor calls when "..." suffices.
Rik <rik@octave.org>
parents: 23804
diff changeset
272 type = val.is_user_script () ? "script" : "function";
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
273 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
274 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
275 else
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
276 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
277 // We might find a file that contains only a doc string.
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
278
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
279 load_path& lp = m_interpreter.get_load_path ();
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
280
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
281 file = lp.find_fcn_file (name);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
282 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
283 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
284 else
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
285 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
286 // File query.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
287
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
288 load_path& lp = m_interpreter.get_load_path ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
289
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
290 // For compatibility: "file." queries "file".
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
291 if (name.size () > 1 && name[name.size () - 1] == '.')
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
292 file = lp.find_file (name.substr (0, name.size () - 1));
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
293 else
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
294 file = lp.find_file (name);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
295
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
296 file = sys::env::make_absolute (file);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
297 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
298
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
299 return file;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
300 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
301
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
302 std::string help_system::which (const std::string& name) const
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
303 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
304 std::string type;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
305
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
306 return which (name, type);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
307 }
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
308
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
309 string_vector help_system::make_name_list (void) const
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
310 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
311 const static string_vector keywords
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
312 = Fiskeyword ()(0).string_vector_value ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
313
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
314 const static int key_len = keywords.numel ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
315
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
316 symbol_table& symtab = m_interpreter.get_symbol_table ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
317
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
318 const string_vector bif = symtab.built_in_function_names ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
319 const int bif_len = bif.numel ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
320
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
321 const string_vector cfl = symtab.cmdline_function_names ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
322 const int cfl_len = cfl.numel ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
323
26661
cf9e10ce3351 move variable values from symbol_record objects to stack_frame objects
John W. Eaton <jwe@octave.org>
parents: 26594
diff changeset
324 const string_vector lcl = m_interpreter.variable_names ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
325 const int lcl_len = lcl.numel ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
326
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
327 load_path& lp = m_interpreter.get_load_path ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
328
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
329 const string_vector ffl = lp.fcn_names ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
330 const int ffl_len = ffl.numel ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
331
27016
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 26679
diff changeset
332 const string_vector afl = m_interpreter.autoloaded_functions ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
333 const int afl_len = afl.numel ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
334
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
335 const string_vector lfl = local_functions ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
336 const int lfl_len = lfl.numel ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
337
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
338 const int total_len
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
339 = key_len + bif_len + cfl_len + lcl_len + ffl_len + afl_len + lfl_len;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
340
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
341 string_vector list (total_len);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
342
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
343 // Put all the symbols in one big list.
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
344
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
345 int j = 0;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
346 int i = 0;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
347
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
348 for (i = 0; i < key_len; i++)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
349 list[j++] = keywords[i];
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
350
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
351 for (i = 0; i < bif_len; i++)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
352 list[j++] = bif[i];
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
353
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
354 for (i = 0; i < cfl_len; i++)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
355 list[j++] = cfl[i];
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
356
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
357 for (i = 0; i < lcl_len; i++)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
358 list[j++] = lcl[i];
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
359
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
360 for (i = 0; i < ffl_len; i++)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
361 list[j++] = ffl[i];
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
362
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
363 for (i = 0; i < afl_len; i++)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
364 list[j++] = afl[i];
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
365
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
366 for (i = 0; i < lfl_len; i++)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
367 list[j++] = lfl[i];
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
368
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
369 return list;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
370 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
371
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
372 void help_system::get_help_text (const std::string& name, std::string& text,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
373 std::string& format) const
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
374 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
375 bool symbol_found = false;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
376 text = raw_help (name, symbol_found);
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
377
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
378 format = "Not found";
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
379 if (symbol_found)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
380 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
381 size_t idx = -1;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
382 if (text.empty ())
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
383 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
384 format = "Not documented";
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
385 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
386 else if (looks_like_texinfo (text, idx))
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
387 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
388 format = "texinfo";
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
389 text.erase (0, idx);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
390 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
391 else if (looks_like_html (text))
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
392 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
393 format = "html";
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
394 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
395 else
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
396 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
397 format = "plain text";
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
398 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
399 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
400 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
401
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
402 void help_system::get_help_text_from_file (const std::string& fname,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
403 std::string& text,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
404 std::string& format) const
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
405 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
406 bool symbol_found = false;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
407
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
408 std::string f;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
409
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
410 raw_help_from_file (fname, text, f, symbol_found);
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
411
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
412 format = "Not found";
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
413 if (symbol_found)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
414 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
415 size_t idx = -1;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
416 if (text.empty ())
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
417 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
418 format = "Not documented";
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
419 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
420 else if (looks_like_texinfo (text, idx))
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
421 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
422 format = "texinfo";
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
423 text.erase (0, idx);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
424 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
425 else if (looks_like_html (text))
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
426 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
427 format = "html";
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
428 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
429 else
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
430 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
431 format = "plain text";
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
432 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
433 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
434 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
435
25460
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
436 std::string help_system::init_built_in_docstrings_file (void)
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
437 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
438 std::string df = sys::env::getenv ("OCTAVE_BUILT_IN_DOCSTRINGS_FILE");
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
439
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
440 std::string dir_sep = sys::file_ops::dir_sep_str ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
441
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
442 if (df.empty ())
25460
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
443 df = config::oct_etc_dir () + dir_sep + "built-in-docstrings";
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
444
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
445 return df;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
446 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
447
25460
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
448 std::string help_system::init_doc_cache_file (void)
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
449 {
25460
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
450 std::string def_file = config::prepend_octave_home (OCTAVE_DOC_CACHE_FILE);
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
451
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
452 std::string env_file = sys::env::getenv ("OCTAVE_DOC_CACHE_FILE");
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
453
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
454 return (env_file.empty () ? def_file : env_file);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
455 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
456
25460
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
457 std::string help_system::init_info_file (void)
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
458 {
25460
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
459 std::string std_info_file = config::prepend_octave_home (OCTAVE_INFOFILE);
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
460
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
461 std::string oct_info_file = sys::env::getenv ("OCTAVE_INFO_FILE");
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
462
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
463 return (oct_info_file.empty () ? std_info_file : oct_info_file);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
464 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
465
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
466 std::string help_system::init_info_program (void)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
467 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
468 std::string info_prog = sys::env::getenv ("OCTAVE_INFO_PROGRAM");
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
469
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
470 if (info_prog.empty ())
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
471 info_prog = "info";
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
472
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
473 return info_prog;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
474 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
475
25460
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
476 std::string help_system::init_texi_macros_file (void)
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
477 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
478 std::string def_file
25460
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
479 = config::prepend_octave_home (OCTAVE_TEXI_MACROS_FILE);
22295
12f1d273d22a maint: Remove trailing spaces from code.
Rik <rik@octave.org>
parents: 22199
diff changeset
480
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
481 std::string env_file = sys::env::getenv ("OCTAVE_TEXI_MACROS_FILE");
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
482
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
483 return (env_file.empty () ? def_file : env_file);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
484 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
485
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
486 // Return a vector of all functions from this file,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
487 // for use in command line auto-completion.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
488 string_vector help_system::local_functions (void) const
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
489 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
490 string_vector retval;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
491
27202
23962b243bad eliminate direct access to call stack in help functions
John W. Eaton <jwe@octave.org>
parents: 27102
diff changeset
492 tree_evaluator& tw = m_interpreter.get_evaluator ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
493
27202
23962b243bad eliminate direct access to call stack in help functions
John W. Eaton <jwe@octave.org>
parents: 27102
diff changeset
494 octave_user_code *curr_fcn = tw.current_user_code ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
495
25394
9e39a53b4e00 make listing local functions for command completion work again (bug #53925)
John W. Eaton <jwe@octave.org>
parents: 25388
diff changeset
496 if (! curr_fcn)
9e39a53b4e00 make listing local functions for command completion work again (bug #53925)
John W. Eaton <jwe@octave.org>
parents: 25388
diff changeset
497 return retval;
9e39a53b4e00 make listing local functions for command completion work again (bug #53925)
John W. Eaton <jwe@octave.org>
parents: 25388
diff changeset
498
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
499 // All subfunctions are listed in the top-level function of this file.
25394
9e39a53b4e00 make listing local functions for command completion work again (bug #53925)
John W. Eaton <jwe@octave.org>
parents: 25388
diff changeset
500 // If curr_fcn is a subfunction, then there must be a parent and
9e39a53b4e00 make listing local functions for command completion work again (bug #53925)
John W. Eaton <jwe@octave.org>
parents: 25388
diff changeset
501 // curr_fcn will always be valid in and after executing this loop.
9e39a53b4e00 make listing local functions for command completion work again (bug #53925)
John W. Eaton <jwe@octave.org>
parents: 25388
diff changeset
502
9e39a53b4e00 make listing local functions for command completion work again (bug #53925)
John W. Eaton <jwe@octave.org>
parents: 25388
diff changeset
503 while (curr_fcn->is_subfunction ())
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
504 {
24361
8bcfddad15ec use shared_ptr to manage symbol_scope objects
John W. Eaton <jwe@octave.org>
parents: 24270
diff changeset
505 symbol_scope pscope = curr_fcn->parent_fcn_scope ();
27745
7a45100a40c4 allow private scripts to be called from other private scripts
John W. Eaton <jwe@octave.org>
parents: 27461
diff changeset
506 curr_fcn = pscope.user_code ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
507 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
508
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
509 // Get subfunctions.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
510 const std::list<std::string> names = curr_fcn->subfunction_names ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
511
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
512 size_t sz = names.size ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
513 retval.resize (sz);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
514
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
515 // Loop over them.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
516 size_t i = 0;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
517 for (const auto& nm : names)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
518 retval(i++) = nm;
22556
121e9639b604 doc: Correctly get last entry from DOCSTRINGS file (bug #49224).
Rik <rik@octave.org>
parents: 22407
diff changeset
519
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
520 return retval;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
521 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
522
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
523 bool help_system::raw_help_from_symbol_table (const std::string& nm,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
524 std::string& h, std::string& w,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
525 bool& symbol_found) const
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
526 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
527 bool retval = false;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
528
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
529 symbol_table& symtab = m_interpreter.get_symbol_table ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
530
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
531 octave_value val = symtab.find_function (nm);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
532
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
533 if (val.is_defined ())
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
534 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
535 octave_function *fcn = val.function_value ();
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
536
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
537 if (fcn)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
538 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
539 symbol_found = true;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
540
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
541 h = fcn->doc_string ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
542
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
543 retval = true;
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
544
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
545 w = fcn->fcn_file_name ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
546
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
547 if (w.empty ())
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
548 w = fcn->is_user_function () ? "command-line function"
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
549 : "built-in function";
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
550 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
551 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
552
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
553 return retval;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
554 }
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
555
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
556 bool help_system::raw_help_from_file (const std::string& nm,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
557 std::string& h, std::string& file,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
558 bool& symbol_found) const
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
559 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
560 bool retval = false;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
561
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
562 h = get_help_from_file (nm, symbol_found, file);
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
563
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
564 if (h.length () > 0)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
565 retval = true;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
566
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
567 return retval;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
568 }
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
569
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
570 bool
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
571 help_system::raw_help_from_docstrings_file (const std::string& nm,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
572 std::string& h,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
573 bool& symbol_found) const
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
574 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
575 typedef std::pair<std::streampos, std::streamoff> txt_limits_type;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
576 typedef std::map<std::string, txt_limits_type> help_txt_map_type;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
577
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
578 static help_txt_map_type help_txt_map;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
579 static bool initialized = false;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
580
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
581 h = "";
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
582 symbol_found = false;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
583
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
584 // FIXME: Should we cache the timestamp of the file and reload the
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
585 // offsets if it changes? Or just warn about that? Or just ignore
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
586 // it, and assume it won't change?
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
587
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
588 if (! initialized)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
589 {
25604
ca413f326224 Fix lifetime issues with temporary char arrays returned by get_ASCII_filename (bug #54299).
Markus Mützel <markus.muetzel@gmx.de>
parents: 25548
diff changeset
590 std::string ascii_fname
27102
84ff9953faa1 where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27101
diff changeset
591 = sys::get_ASCII_filename (m_built_in_docstrings_file);
25604
ca413f326224 Fix lifetime issues with temporary char arrays returned by get_ASCII_filename (bug #54299).
Markus Mützel <markus.muetzel@gmx.de>
parents: 25548
diff changeset
592
ca413f326224 Fix lifetime issues with temporary char arrays returned by get_ASCII_filename (bug #54299).
Markus Mützel <markus.muetzel@gmx.de>
parents: 25548
diff changeset
593 std::ifstream file (ascii_fname.c_str (),
ca413f326224 Fix lifetime issues with temporary char arrays returned by get_ASCII_filename (bug #54299).
Markus Mützel <markus.muetzel@gmx.de>
parents: 25548
diff changeset
594 std::ios::in | std::ios::binary);
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
595
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
596 if (! file)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
597 error ("failed to open docstrings file: %s",
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
598 m_built_in_docstrings_file.c_str ());
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
599
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
600 // Ignore header;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
601 file.ignore (std::numeric_limits<std::streamsize>::max(), 0x1d);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
602
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
603 if (file.eof ())
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
604 error ("invalid built-in-docstrings file!");
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
605
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
606 // FIXME: eliminate fixed buffer size.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
607 size_t bufsize = 1000;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
608 OCTAVE_LOCAL_BUFFER (char, buf, bufsize);
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
609
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
610 while (! file.eof ())
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
611 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
612 std::string name;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
613 int i = 0;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
614 int c;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
615 while (file && (c = file.get ()) != std::istream::traits_type::eof ())
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
616 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
617 if (c == '\n' || c == '\r')
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
618 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
619 buf[i] = '\0';
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
620 name = buf;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
621 break;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
622 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
623 else
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
624 buf[i++] = c;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
625 }
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
626
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
627 // Skip @c FILENAME which is part of current DOCSTRINGS
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
628 // syntax. This may disappear if a specific format for
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
629 // docstring files is developed.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
630 while (file
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
631 && (c = file.get ()) != std::istream::traits_type::eof ()
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
632 && c != '\n' && c != '\r')
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
633 ; // skip text
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
634
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
635 // skip newline characters
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
636 while (file
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
637 && (c = file.get ()) != std::istream::traits_type::eof ()
26347
09a793a92c11 help.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents: 25604
diff changeset
638 && (c == '\n' || c == '\r'))
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
639 ; // skip text
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
640
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
641 file.unget ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
642
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
643 // Position of beginning of help text.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
644 std::streampos beg = file.tellg ();
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
645
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
646 // Skip help text.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
647 file.ignore (std::numeric_limits<std::streamsize>::max(), 0x1d);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
648
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
649 // Position of end of help text.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
650 std::streamoff len;
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
651
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
652 if (! file.eof ())
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
653 len = file.tellg () - beg - 1;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
654 else
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
655 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
656 file.seekg (0, file.end);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
657 len = file.tellg () - beg - 1;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
658 file.setstate (file.eofbit); // reset eof flag
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
659 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
660
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
661 help_txt_map[name] = txt_limits_type (beg, len);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
662 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
663
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
664 initialized = true;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
665 }
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
666
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
667 help_txt_map_type::const_iterator it = help_txt_map.find (nm);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
668
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
669 if (it != help_txt_map.end ())
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
670 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
671 txt_limits_type txt_limits = it->second;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
672
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
673 std::streampos beg = txt_limits.first;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
674 std::streamoff len = txt_limits.second;
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
675
25604
ca413f326224 Fix lifetime issues with temporary char arrays returned by get_ASCII_filename (bug #54299).
Markus Mützel <markus.muetzel@gmx.de>
parents: 25548
diff changeset
676 std::string ascii_fname
27102
84ff9953faa1 where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27101
diff changeset
677 = sys::get_ASCII_filename (m_built_in_docstrings_file);
25604
ca413f326224 Fix lifetime issues with temporary char arrays returned by get_ASCII_filename (bug #54299).
Markus Mützel <markus.muetzel@gmx.de>
parents: 25548
diff changeset
678
ca413f326224 Fix lifetime issues with temporary char arrays returned by get_ASCII_filename (bug #54299).
Markus Mützel <markus.muetzel@gmx.de>
parents: 25548
diff changeset
679 std::ifstream file (ascii_fname.c_str (),
ca413f326224 Fix lifetime issues with temporary char arrays returned by get_ASCII_filename (bug #54299).
Markus Mützel <markus.muetzel@gmx.de>
parents: 25548
diff changeset
680 std::ios::in | std::ios::binary);
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
681
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
682 if (! file)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
683 error ("failed to open docstrings file: %s",
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
684 m_built_in_docstrings_file.c_str ());
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
685
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
686 file.seekg (beg);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
687
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
688 size_t txt_len = len;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
689 OCTAVE_LOCAL_BUFFER (char, buf, txt_len + 1);
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
690
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
691 file.read (buf, txt_len);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
692
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
693 buf[txt_len] = '\0';
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
694
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
695 h = buf;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
696
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
697 symbol_found = true;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
698 }
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
699
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
700 return symbol_found;
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
701 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
702
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
703 // FIXME: It's not likely that this does the right thing now.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
704
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
705 string_vector make_name_list (void)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
706 {
25336
389757b7b6af eliminate redundant octave:: namespace tags
John W. Eaton <jwe@octave.org>
parents: 25103
diff changeset
707 help_system& help_sys = __get_help_system__ ("make_name_list");
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
708
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
709 return help_sys.make_name_list ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
710 }
22198
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
711 }
f6181638f6c5 search docstrings file for built-in and dld function help text (bug #48554)
John W. Eaton <jwe@octave.org>
parents: 22172
diff changeset
712
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
713 DEFMETHOD (get_help_text, interp, args, ,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
714 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
715 @deftypefn {} {[@var{text}, @var{format}] =} get_help_text (@var{name})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
716 Return the raw help text of function @var{name}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
717
27438
7db34a40cd23 doc: Improve documentation for get_help_text, get_help_text_from_file.
Rik <rik@octave.org>
parents: 27361
diff changeset
718 The raw help text is returned in @var{text} and the format in @var{format}.
7db34a40cd23 doc: Improve documentation for get_help_text, get_help_text_from_file.
Rik <rik@octave.org>
parents: 27361
diff changeset
719 The format is a string which is one of @qcode{"texinfo"}, @qcode{"html"}, or
7db34a40cd23 doc: Improve documentation for get_help_text, get_help_text_from_file.
Rik <rik@octave.org>
parents: 27361
diff changeset
720 @w{@qcode{"plain text"}}.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
721 @seealso{get_help_text_from_file}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
722 @end deftypefn */)
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 389
diff changeset
723 {
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
724 if (args.length () != 1)
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
725 print_usage ();
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1742
diff changeset
726
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
727 const std::string name = args(0).xstring_value ("get_help_text: NAME must be a string");
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 389
diff changeset
728
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
729 octave::help_system& help_sys = interp.get_help_system ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
730
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20922
diff changeset
731 std::string text, format;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
732
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
733 help_sys.get_help_text (name, text, format);
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
734
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20922
diff changeset
735 return ovl (text, format);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 389
diff changeset
736 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 389
diff changeset
737
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
738 DEFMETHOD (get_help_text_from_file, interp, args, ,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
739 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
740 @deftypefn {} {[@var{text}, @var{format}] =} get_help_text_from_file (@var{fname})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
741 Return the raw help text from the file @var{fname}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
742
27438
7db34a40cd23 doc: Improve documentation for get_help_text, get_help_text_from_file.
Rik <rik@octave.org>
parents: 27361
diff changeset
743 The raw help text is returned in @var{text} and the format in @var{format}.
7db34a40cd23 doc: Improve documentation for get_help_text, get_help_text_from_file.
Rik <rik@octave.org>
parents: 27361
diff changeset
744 The format is a string which is one of @qcode{"texinfo"}, @qcode{"html"}, or
7db34a40cd23 doc: Improve documentation for get_help_text, get_help_text_from_file.
Rik <rik@octave.org>
parents: 27361
diff changeset
745 @w{@qcode{"plain text"}}.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
746 @seealso{get_help_text}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
747 @end deftypefn */)
9806
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
748 {
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
749 if (args.length () != 1)
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
750 print_usage ();
9806
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
751
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
752 const std::string fname = args(0).xstring_value ("get_help_text_from_file: NAME must be a string");
9806
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
753
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
754 octave::help_system& help_sys = interp.get_help_system ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
755
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20922
diff changeset
756 std::string text, format;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
757
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
758 help_sys.get_help_text_from_file (fname, text, format);
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
759
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20922
diff changeset
760 return ovl (text, format);
9806
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
23065
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
763 // Return a cell array of strings containing the names of all operators.
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8672
diff changeset
764
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8672
diff changeset
765 DEFUN (__operators__, , ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
766 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
767 @deftypefn {} {} __operators__ ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
768 Undocumented internal function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
769 @end deftypefn */)
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
770 {
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
771 return ovl (Cell (octave::operator_names));
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
772 }
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
773
23065
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
774 // Return a cell array of strings containing the names of all keywords.
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
775 // iskeyword() function is located in lex.ll and is based on what the parser
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
776 // thinks is a keyword.
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8672
diff changeset
777
23065
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
778 DEFALIAS (__keywords__, iskeyword)
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 572
diff changeset
779
23065
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
780 // Return a cell array of strings with the names of all builtin functions.
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8672
diff changeset
781
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23553
diff changeset
782 DEFMETHOD (__builtins__, interp, , ,
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23553
diff changeset
783 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
784 @deftypefn {} {} __builtins__ ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
785 Undocumented internal function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
786 @end deftypefn */)
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
787 {
23693
b9378eff6d13 move symbol_table class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23604
diff changeset
788 octave::symbol_table& symtab = interp.get_symbol_table ();
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23553
diff changeset
789
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23553
diff changeset
790 const string_vector bif = symtab.built_in_function_names ();
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
791
21127
df7891224709 maint: Use "return ovl (...)" in DEFUN macros.
Rik <rik@octave.org>
parents: 21100
diff changeset
792 return ovl (Cell (bif));
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
793 }
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
794
23553
14723784b9f2 don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents: 23466
diff changeset
795 DEFMETHOD (localfunctions, interp, args, ,
14723784b9f2 don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents: 23466
diff changeset
796 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
797 @deftypefn {} {} localfunctions ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
798 Return a list of all local functions, i.e., subfunctions, within the current
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
799 file.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
800
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
801 The return value is a column cell array of function handles to all local
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
802 functions accessible from the function from which @code{localfunctions} is
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
803 called. Nested functions are @emph{not} included in the list.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
804
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
805 If the call is from the command line, an anonymous function, or a script,
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
806 the return value is an empty cell array.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
807
22974
ecc5eeada8dc Don't mark nested functions in primary function as subfunctions.
Rik <rik@octave.org>
parents: 22885
diff changeset
808 @seealso{functions}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
809 @end deftypefn */)
21765
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
810 {
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
811 if (args.length () != 0)
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
812 print_usage ();
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
813
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
814 Cell retval;
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
815
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
816 // Find the main function we are in.
27202
23962b243bad eliminate direct access to call stack in help functions
John W. Eaton <jwe@octave.org>
parents: 27102
diff changeset
817 octave::tree_evaluator& tw = interp.get_evaluator ();
23962b243bad eliminate direct access to call stack in help functions
John W. Eaton <jwe@octave.org>
parents: 27102
diff changeset
818 octave_user_code *parent_fcn = tw.debug_user_code ();
21765
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
819
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
820 if (! parent_fcn)
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
821 return ovl (retval);
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
822
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
823 // Find the subfunctions of this function.
22974
ecc5eeada8dc Don't mark nested functions in primary function as subfunctions.
Rik <rik@octave.org>
parents: 22885
diff changeset
824 // 1) subfunction_names contains only valid subfunctions
ecc5eeada8dc Don't mark nested functions in primary function as subfunctions.
Rik <rik@octave.org>
parents: 22885
diff changeset
825 // 2) subfunctions contains both nested functions and subfunctions
21765
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
826 const std::list<std::string> names = parent_fcn->subfunction_names ();
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
827 const std::map<std::string, octave_value> h = parent_fcn->subfunctions ();
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
828
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
829 size_t sz = names.size ();
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
830 retval.resize (dim_vector (sz, 1));
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
831
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
832 // loop over them.
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
833 size_t i = 0;
22862
e365e87371a3 maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents: 22825
diff changeset
834 for (const auto& nm : names)
21765
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
835 {
22862
e365e87371a3 maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents: 22825
diff changeset
836 std::map<std::string, octave_value>::const_iterator nm_fcn = h.find (nm);
22974
ecc5eeada8dc Don't mark nested functions in primary function as subfunctions.
Rik <rik@octave.org>
parents: 22885
diff changeset
837 if (nm_fcn != h.end ())
22862
e365e87371a3 maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents: 22825
diff changeset
838 retval(i++) = octave_value (new octave_fcn_handle (nm_fcn->second, nm));
21765
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
839 }
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
840
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
841 return ovl (retval);
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
842 }
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
843
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
844 /*
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
845 %!test
26679
2b6aa96a5c82 create BIST temporary files in tempdir instead of P_tmpdir (bug #55565)
Mike Miller <mtmiller@octave.org>
parents: 26677
diff changeset
846 %! f = tempname (tempdir (), "oct_");
27361
a7d21a6a7922 BIST should not rely on the current directory to be writable.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 26594
diff changeset
847 %! [~, fcn_name] = fileparts (f);
22016
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
848 %! f = [f ".m"];
26677
33f79d94f21f Create any BIST temporary files in writable temporary directory (bug #55565).
Rik <rik@octave.org>
parents: 26661
diff changeset
849 %! save_path = path ();
22016
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
850 %! unwind_protect
26679
2b6aa96a5c82 create BIST temporary files in tempdir instead of P_tmpdir (bug #55565)
Mike Miller <mtmiller@octave.org>
parents: 26677
diff changeset
851 %! addpath (tempdir ());
22016
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
852 %! fid = fopen (f, "w+");
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
853 %! fprintf (fid, "function z = %s\n z = localfunctions; end\n", fcn_name);
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
854 %! fprintf (fid, "function z = b(x)\n z = x+1; end\n");
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
855 %! fprintf (fid, "function z = c(x)\n z = 2*x; end\n");
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
856 %! fclose (fid);
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
857 %! d = eval (fcn_name);
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
858 %! assert (size (d), [2, 1]);
22974
ecc5eeada8dc Don't mark nested functions in primary function as subfunctions.
Rik <rik@octave.org>
parents: 22885
diff changeset
859 %! assert (d{1} (3), 4);
ecc5eeada8dc Don't mark nested functions in primary function as subfunctions.
Rik <rik@octave.org>
parents: 22885
diff changeset
860 %! assert (d{2} (3), 6);
22016
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
861 %! unwind_protect_cleanup
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
862 %! unlink (f);
26677
33f79d94f21f Create any BIST temporary files in writable temporary directory (bug #55565).
Rik <rik@octave.org>
parents: 26661
diff changeset
863 %! path (save_path);
22016
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
864 %! end_unwind_protect
21765
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
865 */
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
866
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
867 DEFMETHOD (__which__, interp, args, ,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
868 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
869 @deftypefn {} {} __which__ (@var{name}, @dots{})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
870 Undocumented internal function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
871 @end deftypefn */)
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 572
diff changeset
872 {
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
873 octave::help_system& help_sys = interp.get_help_system ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
874
20996
20bd3d4fabad Clean up instances of make_argv().
Rik <rik@octave.org>
parents: 20940
diff changeset
875 string_vector argv = args.make_argv ();
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1742
diff changeset
876
20922
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
877 int nargin = argv.numel ();
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 572
diff changeset
878
20922
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
879 octave_map m (dim_vector (1, nargin));
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 572
diff changeset
880
20922
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
881 Cell names (1, nargin);
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
882 Cell files (1, nargin);
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
883 Cell types (1, nargin);
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
884
20922
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
885 for (int i = 0; i < nargin; i++)
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
886 {
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
887 std::string name = argv[i];
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
888
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
889 std::string type;
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
890
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
891 std::string file = help_sys.which (name, type);
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
892
20922
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
893 names(i) = name;
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
894 files(i) = file;
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
895 types(i) = type;
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
896 }
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
897
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
898 m.assign ("name", names);
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
899 m.assign ("file", files);
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
900 m.assign ("type", types);
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
901
20922
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
902 return ovl (m);
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 572
diff changeset
903 }
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 572
diff changeset
904
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8672
diff changeset
905 // 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
906 // 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
907 // the current path.
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8672
diff changeset
908
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
909 DEFMETHOD (__list_functions__, interp, args, ,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
910 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
911 @deftypefn {} {@var{retval} =} __list_functions__ ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
912 @deftypefnx {} {@var{retval} =} __list_functions__ (@var{directory})
22337
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
913 Return a list of all functions (.m and .oct functions) in the load path.
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
914
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
915 If the optional argument @var{directory} is given then list only the functions
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
916 in that directory.
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
917 @seealso{path}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
918 @end deftypefn */)
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
919 {
8863
34a821854961 pkg.m (generate_lookfor_cache): generate a DOC file for each directory
Jason Riedy <jason@acm.org>
parents: 8861
diff changeset
920 octave_value retval;
5447
051ddd7a6681 [project @ 2005-09-14 05:18:23 by jwe]
jwe
parents: 5399
diff changeset
921
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
922 octave::load_path& lp = interp.get_load_path ();
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
923
22337
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
924 if (args.length () == 0)
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
925 {
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
926 // Get list of all functions
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
927 string_vector ffl = lp.fcn_names ();
27016
9b261300a001 move file-scope static autoload map variable and functions to evaluator
John W. Eaton <jwe@octave.org>
parents: 26679
diff changeset
928 string_vector afl = interp.autoloaded_functions ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
929
22337
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
930 retval = Cell (ffl.append (afl));
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
931 }
20581
fd0efcdb3718 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
932 else
5447
051ddd7a6681 [project @ 2005-09-14 05:18:23 by jwe]
jwe
parents: 5399
diff changeset
933 {
20700
68e3a747ca02 rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents: 20678
diff changeset
934 std::string dir = args(0).xstring_value ("__list_functions__: DIRECTORY argument must be a string");
8863
34a821854961 pkg.m (generate_lookfor_cache): generate a DOC file for each directory
Jason Riedy <jason@acm.org>
parents: 8861
diff changeset
935
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
936 string_vector fl = lp.files (dir, true);
19403
03067dab10ca Use stricter input validation when looking for a string as input (bug #42651).
Rik <rik@octave.org>
parents: 19269
diff changeset
937
22337
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
938 // Return a sorted list with unique entries (in case of .m and .oct
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
939 // versions of the same function in a given directory, for example).
20581
fd0efcdb3718 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
940 fl.sort (true);
8863
34a821854961 pkg.m (generate_lookfor_cache): generate a DOC file for each directory
Jason Riedy <jason@acm.org>
parents: 8861
diff changeset
941
20581
fd0efcdb3718 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
942 retval = Cell (fl);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
943 }
5447
051ddd7a6681 [project @ 2005-09-14 05:18:23 by jwe]
jwe
parents: 5399
diff changeset
944
051ddd7a6681 [project @ 2005-09-14 05:18:23 by jwe]
jwe
parents: 5399
diff changeset
945 return retval;
051ddd7a6681 [project @ 2005-09-14 05:18:23 by jwe]
jwe
parents: 5399
diff changeset
946 }
051ddd7a6681 [project @ 2005-09-14 05:18:23 by jwe]
jwe
parents: 5399
diff changeset
947
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
948 DEFMETHOD (built_in_docstrings_file, interp, args, nargout,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
949 doc: /* -*- texinfo -*-
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
950 @deftypefn {} {@var{val} =} built_in_docstrings_file ()
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
951 @deftypefnx {} {@var{old_val} =} built_in_docstrings_file (@var{new_val})
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
952 @deftypefnx {} {} built_in_docstrings_file (@var{new_val}, "local")
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
953 Query or set the internal variable that specifies the name of the
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
954 file containing docstrings for built-in Octave functions.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
955
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
956 The default value is
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
957 @file{@var{octave-home}/share/octave/@var{version}/etc/built-in-docstrings},
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
958 in which @var{octave-home} is the root directory of the Octave installation,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
959 and @var{version} is the Octave version number. The default value may be
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
960 overridden by the environment variable
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
961 @w{@env{OCTAVE_BUILT_IN_DOCSTRINGS_FILE}}, or the command line argument
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
962 @option{--built-in-docstrings-file FNAME}.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
963
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
964 Note: This variable is only used when Octave is initializing itself.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
965 Modifying it during a running session of Octave will have no effect.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
966 @end deftypefn */)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
967 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
968 octave::help_system& help_sys = interp.get_help_system ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
969
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
970 return help_sys.built_in_docstrings_file (args, nargout);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
971 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
972
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
973 DEFMETHOD (doc_cache_file, interp, args, nargout,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
974 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
975 @deftypefn {} {@var{val} =} doc_cache_file ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
976 @deftypefnx {} {@var{old_val} =} doc_cache_file (@var{new_val})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
977 @deftypefnx {} {} doc_cache_file (@var{new_val}, "local")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
978 Query or set the internal variable that specifies the name of the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
979 Octave documentation cache file.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
980
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
981 A cache file significantly improves the performance of the @code{lookfor}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
982 command. The default value is
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
983 @file{@var{octave-home}/share/octave/@var{version}/etc/doc-cache},
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
984 in which @var{octave-home} is the root directory of the Octave installation,
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
985 and @var{version} is the Octave version number.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
986 The default value may be overridden by the environment variable
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
987 @w{@env{OCTAVE_DOC_CACHE_FILE}}, or the command line argument
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
988 @option{--doc-cache-file FNAME}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
989
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
990 When called from inside a function with the @qcode{"local"} option, the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
991 variable is changed locally for the function and any subroutines it calls.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
992 The original variable value is restored when exiting the function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
993 @seealso{doc_cache_create, lookfor, info_program, doc, help, makeinfo_program}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
994 @seealso{lookfor}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
995 @end deftypefn */)
8861
31f864877246 doc and lookfor fixes
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
996 {
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
997 octave::help_system& help_sys = interp.get_help_system ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
998
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
999 return help_sys.doc_cache_file (args, nargout);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1000 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1001
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1002 DEFMETHOD (info_file, interp, args, nargout,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1003 doc: /* -*- texinfo -*-
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1004 @deftypefn {} {@var{val} =} info_file ()
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1005 @deftypefnx {} {@var{old_val} =} info_file (@var{new_val})
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1006 @deftypefnx {} {} info_file (@var{new_val}, "local")
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1007 Query or set the internal variable that specifies the name of the
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1008 Octave info file.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1009
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1010 The default value is
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1011 @file{@var{octave-home}/info/octave.info}, in
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1012 which @var{octave-home} is the root directory of the Octave installation.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1013 The default value may be overridden by the environment variable
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1014 @w{@env{OCTAVE_INFO_FILE}}, or the command line argument
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1015 @option{--info-file FNAME}.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1016
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1017 When called from inside a function with the @qcode{"local"} option, the
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1018 variable is changed locally for the function and any subroutines it calls.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1019 The original variable value is restored when exiting the function.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1020 @seealso{info_program, doc, help, makeinfo_program}
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1021 @end deftypefn */)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1022 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1023 octave::help_system& help_sys = interp.get_help_system ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1024
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1025 return help_sys.info_file (args, nargout);
8861
31f864877246 doc and lookfor fixes
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
1026 }
31f864877246 doc and lookfor fixes
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
1027
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1028 DEFMETHOD (info_program, interp, args, nargout,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1029 doc: /* -*- texinfo -*-
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1030 @deftypefn {} {@var{val} =} info_program ()
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1031 @deftypefnx {} {@var{old_val} =} info_program (@var{new_val})
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1032 @deftypefnx {} {} info_program (@var{new_val}, "local")
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1033 Query or set the internal variable that specifies the name of the
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1034 info program to run.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1035
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1036 The default value is
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1037 @file{@var{octave-home}/libexec/octave/@var{version}/exec/@var{arch}/info}
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1038 in which @var{octave-home} is the root directory of the Octave installation,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1039 @var{version} is the Octave version number, and @var{arch} is the system
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1040 type (for example, @code{i686-pc-linux-gnu}). The default value may be
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1041 overridden by the environment variable
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1042 @w{@env{OCTAVE_INFO_PROGRAM}}, or the command line argument
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1043 @option{--info-program NAME}.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1044
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1045 When called from inside a function with the @qcode{"local"} option, the
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1046 variable is changed locally for the function and any subroutines it calls.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1047 The original variable value is restored when exiting the function.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1048 @seealso{info_file, doc, help, makeinfo_program}
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1049 @end deftypefn */)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1050 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1051 octave::help_system& help_sys = interp.get_help_system ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1052
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1053 return help_sys.info_program (args, nargout);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1054 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1055
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1056 DEFMETHOD (makeinfo_program, interp, args, nargout,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1057 doc: /* -*- texinfo -*-
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1058 @deftypefn {} {@var{val} =} makeinfo_program ()
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1059 @deftypefnx {} {@var{old_val} =} makeinfo_program (@var{new_val})
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1060 @deftypefnx {} {} makeinfo_program (@var{new_val}, "local")
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1061 Query or set the internal variable that specifies the name of the
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1062 program that Octave runs to format help text containing
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1063 Texinfo markup commands.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1064
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1065 The default value is @code{makeinfo}.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1066
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1067 When called from inside a function with the @qcode{"local"} option, the
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1068 variable is changed locally for the function and any subroutines it calls.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1069 The original variable value is restored when exiting the function.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1070 @seealso{texi_macros_file, info_file, info_program, doc, help}
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1071 @end deftypefn */)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1072 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1073 octave::help_system& help_sys = interp.get_help_system ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1074
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1075 return help_sys.makeinfo_program (args, nargout);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1076 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1077
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1078 DEFMETHOD (suppress_verbose_help_message, interp, args, nargout,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1079 doc: /* -*- texinfo -*-
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1080 @deftypefn {} {@var{val} =} suppress_verbose_help_message ()
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1081 @deftypefnx {} {@var{old_val} =} suppress_verbose_help_message (@var{new_val})
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1082 @deftypefnx {} {} suppress_verbose_help_message (@var{new_val}, "local")
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1083 Query or set the internal variable that controls whether Octave
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1084 will add additional help information to the end of the output from
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1085 the @code{help} command and usage messages for built-in commands.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1086
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1087 When called from inside a function with the @qcode{"local"} option, the
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1088 variable is changed locally for the function and any subroutines it calls.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1089 The original variable value is restored when exiting the function.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1090 @end deftypefn */)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1091 {
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1092 octave::help_system& help_sys = interp.get_help_system ();
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1093
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1094 return help_sys.suppress_verbose_help_message (args, nargout);
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1095 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1096
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1097 DEFMETHOD (texi_macros_file, interp, args, nargout,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1098 doc: /* -*- texinfo -*-
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1099 @deftypefn {} {@var{val} =} texi_macros_file ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1100 @deftypefnx {} {@var{old_val} =} texi_macros_file (@var{new_val})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1101 @deftypefnx {} {} texi_macros_file (@var{new_val}, "local")
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1102 Query or set the internal variable that specifies the name of the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1103 file containing Texinfo macros that are prepended to documentation strings
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1104 before they are passed to makeinfo.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1105
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1106 The default value is
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1107 @file{@var{octave-home}/share/octave/@var{version}/etc/macros.texi},
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1108 in which @var{octave-home} is the root directory of the Octave installation,
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1109 and @var{version} is the Octave version number.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1110 The default value may be overridden by the environment variable
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1111 @w{@env{OCTAVE_TEXI_MACROS_FILE}}, or the command line argument
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1112 @option{--texi-macros-file FNAME}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1113
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1114 When called from inside a function with the @qcode{"local"} option, the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1115 variable is changed locally for the function and any subroutines it calls.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1116 The original variable value is restored when exiting the function.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1117 @seealso{makeinfo_program}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1118 @end deftypefn */)
14614
4e9dc46d4125 handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents: 14360
diff changeset
1119 {
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1120 octave::help_system& help_sys = interp.get_help_system ();
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1121
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1122 return help_sys.texi_macros_file (args, nargout);
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
1123 }