annotate libinterp/corefcn/help.cc @ 33230:515c1cc1b45e

display function signature as help text for undocumented functions (bug #65258) * ov-usr-fcn.h, ov-usr-fcn.cc (octave_user_function::signature): New function. * help.cc (get_help_from_fcn): If function is undocumented, set help text to function signature. (help_system::raw_help_for_class): If there is no "." in name, look for class constructor doc string. If no constructor is defined, set help to signature of default constructor.
author John W. Eaton <jwe@octave.org>
date Wed, 20 Mar 2024 23:14:22 -0400
parents 4e0f8b80bd2f
children 92ca2f6c6b85
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
32632
2e484f9f1f18 maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 32589
diff changeset
3 // Copyright (C) 1993-2024 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21200
diff changeset
27 # include "config.h"
1
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
28 #endif
78fd87e624cb [project @ 1993-08-08 01:13:40 by jwe]
jwe
parents:
diff changeset
29
1343
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
30 #include <cstdlib>
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
31 #include <cstring>
94bedeb289e5 [project @ 1995-09-04 00:29:21 by jwe]
jwe
parents: 1315
diff changeset
32
5769
2b9a5ce46678 [project @ 2006-04-18 15:57:06 by jwe]
jwe
parents: 5768
diff changeset
33 #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
34 #include <fstream>
25438
cb1606f78f6b prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents: 25395
diff changeset
35 #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
36 #include <map>
5765
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5738
diff changeset
37 #include <sstream>
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1742
diff changeset
38 #include <string>
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1742
diff changeset
39
3295
35a6d027772c [project @ 1999-10-19 10:13:02 by jwe]
jwe
parents: 3259
diff changeset
40 #include "cmd-edit.h"
35a6d027772c [project @ 1999-10-19 10:13:02 by jwe]
jwe
parents: 3259
diff changeset
41 #include "file-ops.h"
6253
f1676652d808 [project @ 2007-01-24 20:43:36 by jwe]
jwe
parents: 6243
diff changeset
42 #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
43 #include "lo-sysdep.h"
2926
66ef74ee5d9f [project @ 1997-05-05 03:20:52 by jwe]
jwe
parents: 2900
diff changeset
44 #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
45 #include "oct-locbuf.h"
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1742
diff changeset
46 #include "str-vec.h"
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1742
diff changeset
47
23065
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
48 #include "Cell.h"
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
49 #include "builtin-defun-decls.h"
25460
627d6bde9b8d solve installation info initialization problem differently
John W. Eaton <jwe@octave.org>
parents: 25440
diff changeset
50 #include "defaults.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
51 #include "defun.h"
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
52 #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
53 #include "errwarn.h"
1352
19c10b8657d5 [project @ 1995-09-05 08:11:57 by jwe]
jwe
parents: 1350
diff changeset
54 #include "help.h"
2177
0bddc913621b [project @ 1996-05-13 16:36:11 by jwe]
jwe
parents: 2124
diff changeset
55 #include "input.h"
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
56 #include "interpreter-private.h"
23065
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
57 #include "interpreter.h"
5832
5e41e06f6a78 [project @ 2006-05-26 21:41:32 by jwe]
jwe
parents: 5823
diff changeset
58 #include "load-path.h"
30260
bfbe6e528af5 which: report correct info for classdef constructors (bug #49434)
John W. Eaton <jwe@octave.org>
parents: 29961
diff changeset
59 #include "ov-classdef.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
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 31105
diff changeset
77 OCTAVE_BEGIN_NAMESPACE(octave)
29960
939bef0b66e0 merge "namespace octave" and OCTAVE_NAMESPACE_BEGIN/END blocks
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
78
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
79 const static char *const operators[] =
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
80 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
81 "!",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
82 "~",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
83 "!=",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
84 "~=",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
85 R"(")",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
86 "#",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
87 "%",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
88 "#{",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
89 "%{",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
90 "#}",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
91 "%}",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
92 "...",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
93 "&",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
94 "&&",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
95 "'",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
96 "(",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
97 ")",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
98 "*",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
99 "^",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
100 "+",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
101 "++",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
102 ",",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
103 "-",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
104 "--",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
105 ".'",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
106 ".*",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
107 ".^",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
108 "./",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
109 "/",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
110 R"(.\)",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
111 R"(\)",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
112 ":",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
113 ";",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
114 "<",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
115 "<=",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
116 "=",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
117 "==",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
118 ">",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
119 ">=",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
120 "[",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
121 "]",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
122 "|",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
123 "||",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
124 nullptr
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
125 };
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
126
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
127 const static string_vector operator_names (operators);
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
128
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
129 static bool
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
130 looks_like_html (const std::string& msg)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
131 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
132 const std::size_t p1 = msg.find ('\n');
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
133 std::string t = msg.substr (0, p1);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
134 // FIXME: this comparison should be case-insensitive
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
135 const std::size_t p2 = t.find ("<html");
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
136
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
137 return (p2 != std::string::npos);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
138 }
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
139
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
140 static bool
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
141 looks_like_texinfo (const std::string& msg, std::size_t& p1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
142 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
143 p1 = msg.find ('\n');
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
144
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
145 std::string t = msg.substr (0, p1);
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
146
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
147 if (p1 == std::string::npos)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
148 p1 = 0;
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
149
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
150 std::size_t p2 = t.find ("-*- texinfo -*-");
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
151
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
152 return (p2 != std::string::npos);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
153 }
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27037
diff changeset
154
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
155 octave_value
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
156 help_system::built_in_docstrings_file (const octave_value_list& args,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
157 int nargout)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
158 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
159 return set_internal_variable (m_built_in_docstrings_file, args, nargout,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
160 "built_in_docstrings_file", false);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
161 }
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
162
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
163 octave_value
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
164 help_system::doc_cache_file (const octave_value_list& args, int nargout)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
165 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
166 return set_internal_variable (m_doc_cache_file, args, nargout,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
167 "doc_cache_file", false);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
168 }
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
169
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
170 octave_value
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
171 help_system::info_file (const octave_value_list& args, int nargout)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
172 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
173 return set_internal_variable (m_info_file, args, nargout,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
174 "info_file", false);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
175 }
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
176
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
177 octave_value
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
178 help_system::info_program (const octave_value_list& args, int nargout)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
179 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
180 return set_internal_variable (m_info_program, args, nargout,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
181 "info_program", false);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
182 }
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
183
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
184 octave_value
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
185 help_system::makeinfo_program (const octave_value_list& args, int nargout)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
186 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
187 return set_internal_variable (m_makeinfo_program, args, nargout,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
188 "makeinfo_program", false);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
189 }
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
190
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
191 octave_value
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
192 help_system::suppress_verbose_help_message (const octave_value_list& args,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
193 int nargout)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
194 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
195 return set_internal_variable (m_suppress_verbose_help_message, args,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
196 nargout, "suppress_verbose_help_message");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
197 }
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
198
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
199 octave_value
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
200 help_system::texi_macros_file (const octave_value_list& args, int nargout)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
201 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
202 return set_internal_variable (m_texi_macros_file, args, nargout,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
203 "texi_macros_file", false);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
204 }
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
205
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
206 std::string
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
207 help_system::raw_help (const std::string& nm, bool& symbol_found) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
208 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
209 std::string h;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
210 std::string w;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
211 std::string f;
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
212
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
213 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
214
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
215 found = raw_help_from_symbol_table (nm, h, w, symbol_found);
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
216
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
217 if (! found)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
218 found = raw_help_from_file (nm, h, f, symbol_found);
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
219
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
220 bool external_doc = h.compare (0, 12, "external-doc") == 0;
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
221
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
222 if (! found || external_doc)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
223 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
224 std::string tmp_nm = nm;
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
225
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
226 if (external_doc && h.length () > 12 && h[12] == ':')
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
227 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
228
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
229 raw_help_from_docstrings_file (tmp_nm, h, symbol_found);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
232 return h;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
233 }
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
234
32893
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
235 bool
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
236 help_system::get_which_info_from_fcn (const std::string& name, const octave_value& ov_fcn, std::string& file, std::string& type) const
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
237 {
32893
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
238 file = "";
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
239 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
240
32893
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
241 if (ov_fcn.is_function ())
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
242 {
32893
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
243 octave_function *fcn = ov_fcn.function_value ();
26594
088b8a2dcb06 use @CLASS name when searching for @CLASS/METHOD (bug #55501)
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
244
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
245 if (fcn)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
246 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
247 if (fcn->is_classdef_meta ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
248 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
249 octave_classdef_meta *meta_obj
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
250 = dynamic_cast<octave_classdef_meta *> (fcn);
30260
bfbe6e528af5 which: report correct info for classdef constructors (bug #49434)
John W. Eaton <jwe@octave.org>
parents: 29961
diff changeset
251
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
252 file = meta_obj->file_name ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
253
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
254 if (meta_obj->is_classdef_constructor ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
255 type = "class constructor";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
256 else if (meta_obj->is_classdef_method ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
257 type = "class method";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
258 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
259 type = "classdef meta object";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
260 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
261 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
262 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
263 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
264
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
265 if (! file.empty ())
32893
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
266 type = ov_fcn.is_user_script () ? "script" : "function";
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
267 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
268 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
269 if (fcn->is_user_function ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
270 type = "command-line function";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
271 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
272 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
273 file = fcn->src_file_name ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
274 type = "built-in function";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
275 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
276 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
277 }
32893
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
278
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
279 return true;
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
280 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
281 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
282 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
283 // 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
284
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
285 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
286
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
287 file = lp.find_fcn_file (name);
32893
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
288
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
289 if (file.empty ())
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
290 return false;
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
291 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
292 }
30260
bfbe6e528af5 which: report correct info for classdef constructors (bug #49434)
John W. Eaton <jwe@octave.org>
parents: 29961
diff changeset
293
32893
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
294 return false;
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
295 }
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
296
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
297 // FIXME: There is a lot of duplication between the following function
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
298 // and help_system::raw_help_from_symbol_table. Some refactoring would
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
299 // probably be useful.
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
300
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
301 std::string
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
302 help_system::which (const std::string& name,
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
303 std::string& type) const
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
304 {
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
305 std::string file;
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
306
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
307 if (name.empty ())
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
308 return file;
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
309
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
310 type = "";
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
311
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
312 symbol_table& symtab = m_interpreter.get_symbol_table ();
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
313
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
314 size_t pos = name.find ('.');
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
315
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
316 if (pos == std::string::npos)
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
317 {
32893
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
318 // Simple name. If not found, continue looking for packages and
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
319 // classes.
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
320
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
321 octave_value ov_fcn = symtab.find_function (name);
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
322
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
323 if (get_which_info_from_fcn (name, ov_fcn, file, type))
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
324 return file;
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
325 }
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
326
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
327 // NAME contains '.' and must match the following pattern:
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
328 //
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
329 // (package.)*(package|classname).(property|method)*
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
330 //
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
331 // Start by looking up the full name. It could be either a package or
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
332 // a class and we are done. Otherwise, strip the final component and
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
333 // lookup that name. If it is a package, look for a function. If it
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
334 // is a class, look for a property or method.
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
335
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
336 cdef_manager& cdm = m_interpreter.get_cdef_manager ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
337
32893
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
338 // FIXME: In the following search we may load classes. Is that really
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
339 // what we want, or should we just search the loadpath for
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
340 // +pkga/+pkgb/classname/file.m, etc. and attempt to extract help text
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
341 // without actually installing packages and classes into the fcn_info
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
342 // table?
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
343
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
344 // Is NAME a class?
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
345
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
346 cdef_class cls = cdm.find_class (name, false, true);
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
347
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
348 if (cls.ok ())
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
349 {
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
350 // FIXME: Return documentation for the class or the class
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
351 // constructor?
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
352
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
353 file = cls.file_name ();
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
354 type = "classdef class";
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
355
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
356 return file;
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
357 }
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
358
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
359 cdef_package pkg = cdm.find_package (name, false, true);
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
360
32893
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
361 if (pkg.ok ())
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
362 {
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
363 // FIXME: How to get the fill name of a package?
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
364 file = pkg.get_name ();
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
365 type = "package";
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
366
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
367 return file;
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
368 }
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
369
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
370 // Strip final component (might be a property or method name).
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
371
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
372 pos = name.rfind ('.');
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
373 std::string prefix = name.substr (0, pos);
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
374 std::string nm = name.substr (pos+1);
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
375
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
376 // Is PREFIX the name of a class?
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
377
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
378 cls = cdm.find_class (prefix, false, true);
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
379
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
380 if (cls.ok ())
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
381 {
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
382 // FIXME: Should we only find public methods here?
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
383
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
384 octave_value ov_meth = cls.get_method (nm);
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
385
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
386 if (get_which_info_from_fcn (nm, ov_meth, file, type))
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
387 return file;
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
388
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
389 // FIXME: Should we only find public properties here?
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
390
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
391 cdef_property prop = cls.find_property (nm);
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
392
32893
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
393 if (prop.ok ())
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
394 {
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
395 file = cls.file_name ();
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
396 type = "class property";
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
397
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
398 return file;
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
399 }
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
400 }
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
401
32893
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
402 // Or is PREFIX the name of a package?
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
403
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
404 pkg = cdm.find_package (prefix, false, true);
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
405
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
406 if (pkg.ok ())
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
407 {
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
408 octave_value ov_fcn = pkg.find (nm);
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
409
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
410 if (get_which_info_from_fcn (nm, ov_fcn, file, type))
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
411 return file;
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
412 }
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
413
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
414 // File query.
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
415
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
416 load_path& lp = m_interpreter.get_load_path ();
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
417
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
418 // For compatibility: "file." queries "file".
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
419 if (name.size () > 1 && name[name.size () - 1] == '.')
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
420 file = lp.find_file (name.substr (0, name.size () - 1));
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
421 else
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
422 file = lp.find_file (name);
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
423
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
424 file = sys::env::make_absolute (file);
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
425
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
426 if (! file.empty ())
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
427 type = "file";
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
428
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
429 return file;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
430 }
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
431
32589
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
432 std::string
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
433 help_system::which (const std::string& name) const
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
434 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
435 std::string type;
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
436
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
437 return which (name, type);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
438 }
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
439
32589
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
440 string_vector
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
441 help_system::make_name_list () const
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
442 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
443 const static string_vector keywords
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
444 = Fiskeyword ()(0).string_vector_value ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
445
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
446 const static int key_len = keywords.numel ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
447
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
448 symbol_table& symtab = m_interpreter.get_symbol_table ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
449
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
450 const string_vector bif = symtab.built_in_function_names ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
451 const int bif_len = bif.numel ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
452
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
453 const string_vector cfl = symtab.cmdline_function_names ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
454 const int cfl_len = cfl.numel ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
455
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
456 const string_vector lcl = m_interpreter.variable_names ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
457 const int lcl_len = lcl.numel ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
458
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
459 load_path& lp = m_interpreter.get_load_path ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
460
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
461 const string_vector ffl = lp.fcn_names ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
462 const int ffl_len = ffl.numel ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
463
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
464 const string_vector afl = m_interpreter.autoloaded_functions ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
465 const int afl_len = afl.numel ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
466
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
467 const string_vector lfl = local_functions ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
468 const int lfl_len = lfl.numel ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
469
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
470 const int total_len
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
471 = key_len + bif_len + cfl_len + lcl_len + ffl_len + afl_len + lfl_len;
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
472
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
473 string_vector list (total_len);
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
474
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
475 // 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
476
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
477 int j = 0;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
478 int i = 0;
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
479
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
480 for (i = 0; i < key_len; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
481 list[j++] = keywords[i];
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
482
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
483 for (i = 0; i < bif_len; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
484 list[j++] = bif[i];
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
485
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
486 for (i = 0; i < cfl_len; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
487 list[j++] = cfl[i];
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
488
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
489 for (i = 0; i < lcl_len; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
490 list[j++] = lcl[i];
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
491
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
492 for (i = 0; i < ffl_len; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
493 list[j++] = ffl[i];
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
494
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
495 for (i = 0; i < afl_len; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
496 list[j++] = afl[i];
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
497
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
498 for (i = 0; i < lfl_len; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
499 list[j++] = lfl[i];
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
500
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
501 return list;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
502 }
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
503
32589
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
504 void
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
505 help_system::get_help_text (const std::string& name, std::string& text,
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
506 std::string& format) const
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
507 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
508 bool symbol_found = false;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
509 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
510
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
511 format = "Not found";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
512 if (symbol_found)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
513 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
514 std::size_t idx = -1;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
515 if (text.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
516 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
517 format = "Not documented";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
518 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
519 else if (looks_like_texinfo (text, idx))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
520 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
521 format = "texinfo";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
522 text.erase (0, idx);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
523 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
524 else if (looks_like_html (text))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
525 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
526 format = "html";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
527 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
528 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
529 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
530 format = "plain text";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
531 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
532 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
533 }
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
534
32589
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
535 void
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
536 help_system::get_help_text_from_file (const std::string& fname,
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
537 std::string& text,
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
538 std::string& format) const
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
539 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
540 bool symbol_found = false;
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
541
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
542 std::string f;
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
543
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
544 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
545
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
546 format = "Not found";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
547 if (symbol_found)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
548 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
549 std::size_t idx = -1;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
550 if (text.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
551 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
552 format = "Not documented";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
553 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
554 else if (looks_like_texinfo (text, idx))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
555 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
556 format = "texinfo";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
557 text.erase (0, idx);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
558 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
559 else if (looks_like_html (text))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
560 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
561 format = "html";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
562 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
563 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
564 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
565 format = "plain text";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
566 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
567 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
568 }
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
569
32589
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
570 std::string
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
571 help_system::init_built_in_docstrings_file ()
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
572 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
573 std::string df = sys::env::getenv ("OCTAVE_BUILT_IN_DOCSTRINGS_FILE");
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
574
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
575 std::string dir_sep = sys::file_ops::dir_sep_str ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
576
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
577 if (df.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
578 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
579
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
580 return df;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
581 }
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
582
32589
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
583 std::string
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
584 help_system::init_doc_cache_file ()
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
585 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
586 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
587
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
588 std::string env_file = sys::env::getenv ("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
589
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
590 return (env_file.empty () ? def_file : env_file);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
591 }
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
592
32589
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
593 std::string
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
594 help_system::init_info_file ()
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
595 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
596 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
597
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
598 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
599
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
600 return (oct_info_file.empty () ? std_info_file : oct_info_file);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
601 }
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
602
32589
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
603 std::string
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
604 help_system::init_info_program ()
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
605 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
606 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
607
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
608 if (info_prog.empty ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
609 info_prog = "info";
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
610
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
611 return info_prog;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
612 }
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
613
32589
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
614 std::string
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
615 help_system::init_texi_macros_file ()
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
616 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
617 std::string def_file
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
618 = config::prepend_octave_home (OCTAVE_TEXI_MACROS_FILE);
22295
12f1d273d22a maint: Remove trailing spaces from code.
Rik <rik@octave.org>
parents: 22199
diff changeset
619
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
620 std::string env_file = sys::env::getenv ("OCTAVE_TEXI_MACROS_FILE");
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
621
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
622 return (env_file.empty () ? def_file : env_file);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
623 }
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
624
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
625 // Return a vector of all functions from this file,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
626 // for use in command line auto-completion.
32589
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
627 string_vector
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
628 help_system::local_functions () const
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
629 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
630 string_vector retval;
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
631
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
632 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
633
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
634 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
635
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
636 if (! curr_fcn)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
637 return retval;
25394
9e39a53b4e00 make listing local functions for command completion work again (bug #53925)
John W. Eaton <jwe@octave.org>
parents: 25388
diff changeset
638
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
639 // All subfunctions are listed in the top-level function of this file.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
640 // If curr_fcn is a subfunction, then there must be a parent and
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
641 // curr_fcn will always be valid in and after executing this loop.
25394
9e39a53b4e00 make listing local functions for command completion work again (bug #53925)
John W. Eaton <jwe@octave.org>
parents: 25388
diff changeset
642
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
643 while (curr_fcn->is_subfunction ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
644 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
645 symbol_scope pscope = curr_fcn->parent_fcn_scope ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
646 curr_fcn = pscope.user_code ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
647 }
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
648
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
649 // Get subfunctions.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
650 const std::list<std::string> names = curr_fcn->subfunction_names ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
651
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
652 std::size_t sz = names.size ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
653 retval.resize (sz);
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
654
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
655 // Loop over them.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
656 std::size_t i = 0;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
657 for (const auto& nm : names)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
658 retval(i++) = nm;
22556
121e9639b604 doc: Correctly get last entry from DOCSTRINGS file (bug #49224).
Rik <rik@octave.org>
parents: 22407
diff changeset
659
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
660 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
661 }
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
662
32893
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
663 static bool
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
664 get_help_from_fcn (const std::string& fcn_nm, const octave_value& ov_fcn, std::string& help, std::string& what, bool& symbol_found)
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
665 {
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
666 symbol_found = false;
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
667
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
668 help = "";
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
669 what = "";
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
670
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
671 if (ov_fcn.is_function ())
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
672 {
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
673 octave_function *fcn = ov_fcn.function_value ();
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
674
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
675 help = fcn->doc_string (fcn_nm);
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
676 what = fcn->fcn_file_name ();
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
677
33230
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
678 if (help.empty () && ov_fcn.is_user_function ())
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
679 {
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
680 octave_user_function *ufcn = ov_fcn.user_function_value ();
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
681
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
682 if (ufcn->is_classdef_constructor ())
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
683 help = "undocumented constructor: ";
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
684 else if (ufcn->is_classdef_method ())
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
685 help = "undocumented method: ";
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
686 else
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
687 help = "undocumented function: ";
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
688
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
689 help += ufcn->signature ();
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
690 }
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
691
32893
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
692 if (what.empty ())
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
693 what = fcn->is_user_function () ? "command-line function" : "built-in function";
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
694
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
695 symbol_found = true;
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
696 }
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
697
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
698 return symbol_found;
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
699 }
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
700
33139
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
701 bool
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
702 help_system::raw_help_for_class (const cdef_class& cls,
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
703 const std::string& name,
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
704 std::string& help, std::string& what,
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
705 bool& symbol_found) const
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
706 {
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
707 if (cls.ok ())
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
708 {
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
709 // Is the class documented?
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
710 help = cls.doc_string ();
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
711
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
712 if (! help.empty ())
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
713 {
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
714 what = "class";
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
715
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
716 symbol_found = true;
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
717 return true;
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
718 }
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
719
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
720 // Look for constructor.
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
721 std::size_t pos = name.rfind ('.');
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
722
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
723 if (pos != std::string::npos)
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
724 {
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
725 std::string nm = name.substr (pos+1);
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
726
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
727 octave_value ov_meth = cls.get_method (nm);
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
728
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
729 if (get_help_from_fcn (nm, ov_meth, help, what, symbol_found))
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
730 {
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
731 what = "constructor";
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
732 return true;
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
733 }
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
734 }
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
735
33230
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
736 // No dot in name and class is undocumented. Look for documented
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
737 // constructor.
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
738
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
739 octave_value ov_meth = cls.get_method (name);
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
740
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
741 if (get_help_from_fcn (name, ov_meth, help, what, symbol_found))
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
742 {
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
743 what = "constructor";
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
744 symbol_found = true;
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
745 return true;
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
746 }
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
747
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
748 // We found a class, but no docstring for it and there is no
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
749 // constructor explicitly defined.
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
750
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
751 help = "default constructor: obj = " + name + "()";
515c1cc1b45e display function signature as help text for undocumented functions (bug #65258)
John W. Eaton <jwe@octave.org>
parents: 33139
diff changeset
752 what = "constructor";
33139
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
753 symbol_found = true;
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
754 return true;
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
755 }
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
756
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
757 return false;
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
758 }
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
759
32893
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
760 // FIXME: There is a lot of duplication between the following function
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
761 // and help_system::which. Some refactoring would probably be useful.
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
762
32589
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
763 bool
32893
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
764 help_system::raw_help_from_symbol_table (const std::string& name, std::string& help, std::string& what, bool& symbol_found) const
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
765 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
766 symbol_table& symtab = m_interpreter.get_symbol_table ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
767
32893
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
768 size_t pos = name.find ('.');
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
769
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
770 if (pos == std::string::npos)
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
771 {
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
772 // Simple name. If not found, continue looking for packages and
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
773 // classes.
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
774
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
775 octave_value ov_fcn = symtab.find_function (name);
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
776
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
777 // FIXME: it seems like there is a lot of potential for confusion
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
778 // because is_function can also return true for
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
779 // octave_classdef_meta objects.
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
780
32893
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
781 if (! ov_fcn.is_classdef_meta ()
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
782 && get_help_from_fcn (name, ov_fcn, help, what, symbol_found))
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
783 return true;
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
784 }
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
785
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
786 // If NAME does not contain '.', then it should be a package or a
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
787 // class name.
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
788 //
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
789 // If NAME contains '.' it should match the following pattern:
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
790 //
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
791 // (package.)*(package|classname).(property|method)*
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
792 //
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
793 // Start by looking up the full name. It could be either a package or
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
794 // a class and we are done. Otherwise, strip the final component and
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
795 // lookup that name. If it is a package, look for a function. If it
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
796 // is a class, look for a property or method.
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
797
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
798 cdef_manager& cdm = m_interpreter.get_cdef_manager ();
28514
fab862fedf85 allow help to find docstrings for classdef classes and methods (bug #43047)
John W. Eaton <jwe@octave.org>
parents: 28432
diff changeset
799
32893
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
800 // FIXME: In the following search we may load classes. Is that really
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
801 // what we want, or should we just search the loadpath for
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
802 // +pkga/+pkgb/classname/file.m, etc. and attempt to extract help text
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
803 // without actually installing packages and classes into the fcn_info
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
804 // table?
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
805
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
806 // Is NAME a class?
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
807
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
808 cdef_class cls = cdm.find_class (name, false, true);
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
809
33139
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
810 if (raw_help_for_class (cls, name, help, what, symbol_found))
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
811 return true;
28514
fab862fedf85 allow help to find docstrings for classdef classes and methods (bug #43047)
John W. Eaton <jwe@octave.org>
parents: 28432
diff changeset
812
32893
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
813 cdef_package pkg = cdm.find_package (name, false, true);
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
814
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
815 if (pkg.ok ())
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
816 {
32893
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
817 help = "package " + name;
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
818 what = "package";
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
819
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
820 symbol_found = true;
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
821 return true;
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
822 }
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
823
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
824 // Strip final component (might be a property or method name).
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
825
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
826 pos = name.rfind ('.');
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
827 std::string prefix = name.substr (0, pos);
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
828 std::string nm = name.substr (pos+1);
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
829
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
830 // Is PREFIX the name of a class?
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
831
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
832 cls = cdm.find_class (prefix, false, 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
833
33139
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
834 bool found_class = cls.ok ();
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
835
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
836 if (found_class)
32893
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
837 {
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
838 // FIXME: Should we only find public methods here?
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
839
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
840 octave_value ov_meth = cls.get_method (nm);
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
841
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
842 if (get_help_from_fcn (nm, ov_meth, help, what, symbol_found))
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
843 return true;
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
844
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
845 // FIXME: Should we only find public properties here?
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
846
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
847 cdef_property prop = cls.find_property (nm);
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
848
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
849 if (prop.ok ())
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
850 {
32893
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
851 // FIXME: is it supposed to be possible to document
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
852 // properties?
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
853
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
854 help = prop.doc_string ();
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
855 what = "class property";
28514
fab862fedf85 allow help to find docstrings for classdef classes and methods (bug #43047)
John W. Eaton <jwe@octave.org>
parents: 28432
diff changeset
856
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
857 symbol_found = true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
858 return true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
859 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
860 }
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
861
32893
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
862 // Or is PREFIX the name of a package?
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
863
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
864 pkg = cdm.find_package (prefix, false, true);
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
865
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
866 if (pkg.ok ())
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
867 {
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
868 octave_value ov_fcn = pkg.find (nm);
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
869
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
870 if (get_help_from_fcn (nm, ov_fcn, help, what, symbol_found))
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
871 return true;
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
872 }
2faec354b977 improve symbol lookup in help and which functions (bug #65220)
John W. Eaton <jwe@octave.org>
parents: 32632
diff changeset
873
33139
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
874 if (nm == "m" && raw_help_for_class (cls, prefix, help, what, symbol_found))
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
875 return true;
4e0f8b80bd2f Find class/ctor help for 'CLS.m' if CLS has no method named 'm' (bug #65398)
John W. Eaton <jwe@octave.org>
parents: 32930
diff changeset
876
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
877 return false;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
878 }
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
879
32589
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
880 bool
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
881 help_system::raw_help_from_file (const std::string& nm,
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
882 std::string& h, std::string& file,
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
883 bool& symbol_found) const
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
884 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
885 bool retval = false;
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
886
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
887 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
888
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
889 if (h.length () > 0)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
890 retval = true;
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
891
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
892 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
893 }
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
894
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
895 bool
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
896 help_system::raw_help_from_docstrings_file (const std::string& nm,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
897 std::string& h,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
898 bool& symbol_found) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
899 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
900 typedef std::pair<std::streampos, std::streamoff> txt_limits_type;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
901 typedef std::map<std::string, txt_limits_type> help_txt_map_type;
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
902
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
903 static help_txt_map_type help_txt_map;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
904 static bool initialized = false;
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
905
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
906 h = "";
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
907 symbol_found = false;
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
908
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
909 // FIXME: Should we cache the timestamp of the file and reload the
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
910 // offsets if it changes? Or just warn about that? Or just ignore
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
911 // 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
912
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
913 if (! initialized)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
914 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
915 std::ifstream file = sys::ifstream (m_built_in_docstrings_file.c_str (),
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
916 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
917
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
918 if (! file)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
919 error ("failed to open docstrings file: %s",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
920 m_built_in_docstrings_file.c_str ());
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
921
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
922 // Ignore header;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
923 file.ignore (std::numeric_limits<std::streamsize>::max(), 0x1d);
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
924
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
925 if (file.eof ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
926 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
927
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
928 // FIXME: eliminate fixed buffer size.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
929 std::size_t bufsize = 1000;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
930 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
931
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
932 while (! file.eof ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
933 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
934 std::string name;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
935 int i = 0;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
936 int c;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
937 while (file
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
938 && (c = file.get ()) != std::istream::traits_type::eof ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
939 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
940 if (c == '\n' || c == '\r')
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
941 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
942 buf[i] = '\0';
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
943 name = buf;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
944 break;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
945 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
946 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
947 buf[i++] = c;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
948 }
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
949
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
950 // Skip @c FILENAME which is part of current DOCSTRINGS
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
951 // syntax. This may disappear if a specific format for
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
952 // docstring files is developed.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
953 while (file
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
954 && (c = file.get ()) != std::istream::traits_type::eof ()
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
955 && c != '\n' && c != '\r')
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
956 ; // skip text
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
957
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
958 // skip newline characters
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
959 while (file
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
960 && (c = file.get ()) != std::istream::traits_type::eof ()
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
961 && (c == '\n' || c == '\r'))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
962 ; // skip text
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
963
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
964 file.unget ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
965
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
966 // Position of beginning of help text.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
967 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
968
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
969 // Skip help text.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
970 file.ignore (std::numeric_limits<std::streamsize>::max(), 0x1d);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
971
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
972 // Position of end of help text.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
973 std::streamoff len;
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
974
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
975 if (! file.eof ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
976 len = file.tellg () - beg - 1;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
977 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
978 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
979 file.seekg (0, file.end);
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
980 len = file.tellg () - beg - 1;
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
981 file.setstate (file.eofbit); // reset eof flag
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
982 }
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
983
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
984 help_txt_map[name] = txt_limits_type (beg, len);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
985 }
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
986
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
987 initialized = true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
988 }
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
989
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
990 help_txt_map_type::const_iterator it = help_txt_map.find (nm);
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
991
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
992 if (it != help_txt_map.end ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
993 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
994 txt_limits_type txt_limits = it->second;
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
995
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
996 std::streampos beg = txt_limits.first;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
997 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
998
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
999 std::ifstream file = sys::ifstream (m_built_in_docstrings_file.c_str (),
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1000 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
1001
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1002 if (! file)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1003 error ("failed to open docstrings file: %s",
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1004 m_built_in_docstrings_file.c_str ());
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1005
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1006 file.seekg (beg);
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1007
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1008 std::size_t txt_len = len;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1009 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
1010
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1011 file.read (buf, txt_len);
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1012
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1013 buf[txt_len] = '\0';
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1014
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1015 h = buf;
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1016
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1017 symbol_found = true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1018 }
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
1019
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1020 return symbol_found;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1021 }
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1022
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1023 // FIXME: It's not likely that this does the right thing now.
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1024
32589
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
1025 string_vector
05b4479c29d8 maint: C++ style check for libinterp/ before 9.1 release.
Rik <rik@octave.org>
parents: 31771
diff changeset
1026 make_name_list ()
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1027 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1028 help_system& help_sys = __get_help_system__ ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1029
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1030 return help_sys.make_name_list ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1031 }
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29670
diff changeset
1032
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1033 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
1034 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
1035 @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
1036 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
1037
27438
7db34a40cd23 doc: Improve documentation for get_help_text, get_help_text_from_file.
Rik <rik@octave.org>
parents: 27361
diff changeset
1038 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
1039 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
1040 @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
1041 @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
1042 @end deftypefn */)
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 389
diff changeset
1043 {
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
1044 if (args.length () != 1)
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
1045 print_usage ();
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1742
diff changeset
1046
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
1047 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
1048
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
1049 help_system& help_sys = interp.get_help_system ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1050
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20922
diff changeset
1051 std::string text, format;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1052
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1053 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
1054
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20922
diff changeset
1055 return ovl (text, format);
529
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 389
diff changeset
1056 }
7ea224e713cd [project @ 1994-07-20 18:54:27 by jwe]
jwe
parents: 389
diff changeset
1057
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1058 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
1059 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
1060 @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
1061 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
1062
27438
7db34a40cd23 doc: Improve documentation for get_help_text, get_help_text_from_file.
Rik <rik@octave.org>
parents: 27361
diff changeset
1063 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
1064 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
1065 @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
1066 @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
1067 @end deftypefn */)
9806
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
1068 {
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
1069 if (args.length () != 1)
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
1070 print_usage ();
9806
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
1071
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
1072 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
1073
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
1074 help_system& help_sys = interp.get_help_system ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1075
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20922
diff changeset
1076 std::string text, format;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1077
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1078 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
1079
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20922
diff changeset
1080 return ovl (text, format);
9806
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
1081 }
8e345f2fe4d6 improved support for Contents.m files
John W. Eaton <jwe@octave.org>
parents: 9416
diff changeset
1082
23065
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
1083 // 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
1084
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8672
diff changeset
1085 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
1086 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30588
diff changeset
1087 @deftypefn {} {@var{cstr} =} __operators__ ()
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30588
diff changeset
1088 Return a cell array of strings of all possible Octave 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
1089 @end deftypefn */)
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
1090 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
1091 return ovl (Cell (operator_names));
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
1092 }
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
1093
23065
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
1094 // 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
1095 // 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
1096 // 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
1097
23065
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
1098 DEFALIAS (__keywords__, iskeyword)
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 572
diff changeset
1099
23065
7c7a61c2e0ed Replace out-of-date __keywords__ with alias to iskeyword.
Rik <rik@octave.org>
parents: 23052
diff changeset
1100 // 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
1101
23599
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23553
diff changeset
1102 DEFMETHOD (__builtins__, interp, , ,
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23553
diff changeset
1103 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
1104 @deftypefn {} {} __builtins__ ()
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30588
diff changeset
1105 Return a cell array of all builtin (compiled) functions available to Octave.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1106 @end deftypefn */)
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
1107 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
1108 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
1109
5cb3a2bb5e1e don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents: 23553
diff changeset
1110 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
1111
21127
df7891224709 maint: Use "return ovl (...)" in DEFUN macros.
Rik <rik@octave.org>
parents: 21100
diff changeset
1112 return ovl (Cell (bif));
3355
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
1113 }
c4983fc7318f [project @ 1999-11-18 05:20:50 by jwe]
jwe
parents: 3333
diff changeset
1114
23553
14723784b9f2 don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents: 23466
diff changeset
1115 DEFMETHOD (localfunctions, interp, args, ,
14723784b9f2 don't use singleton for call_stack
John W. Eaton <jwe@octave.org>
parents: 23466
diff changeset
1116 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30588
diff changeset
1117 @deftypefn {} {@var{subfcn_list} =} localfunctions ()
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1118 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
1119 file.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1120
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1121 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
1122 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
1123 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
1124
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1125 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
1126 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
1127
22974
ecc5eeada8dc Don't mark nested functions in primary function as subfunctions.
Rik <rik@octave.org>
parents: 22885
diff changeset
1128 @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
1129 @end deftypefn */)
21765
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
1130 {
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
1131 if (args.length () != 0)
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
1132 print_usage ();
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
1133
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
1134 Cell retval;
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
1135
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
1136 // Find the main function we are in.
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
1137 tree_evaluator& tw = interp.get_evaluator ();
28432
71c34141cc2d refactor handling of parent functions and localfunctions
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1138 octave_user_code *caller = tw.debug_user_code ();
21765
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
1139
28432
71c34141cc2d refactor handling of parent functions and localfunctions
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1140 if (! caller)
21765
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
1141 return ovl (retval);
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
1142
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
1143 symbol_scope scope = caller->scope ();
21765
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
1144
28432
71c34141cc2d refactor handling of parent functions and localfunctions
John W. Eaton <jwe@octave.org>
parents: 27932
diff changeset
1145 return ovl (Cell (scope.localfunctions ()));
21765
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
1146 }
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
1147
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
1148 /*
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
1149 %!test
26679
2b6aa96a5c82 create BIST temporary files in tempdir instead of P_tmpdir (bug #55565)
Mike Miller <mtmiller@octave.org>
parents: 26677
diff changeset
1150 %! 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
1151 %! [~, fcn_name] = fileparts (f);
22016
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
1152 %! f = [f ".m"];
26677
33f79d94f21f Create any BIST temporary files in writable temporary directory (bug #55565).
Rik <rik@octave.org>
parents: 26661
diff changeset
1153 %! save_path = path ();
22016
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
1154 %! 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
1155 %! addpath (tempdir ());
22016
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
1156 %! fid = fopen (f, "w+");
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
1157 %! 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
1158 %! 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
1159 %! 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
1160 %! fclose (fid);
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
1161 %! d = eval (fcn_name);
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
1162 %! 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
1163 %! assert (d{1} (3), 4);
ecc5eeada8dc Don't mark nested functions in primary function as subfunctions.
Rik <rik@octave.org>
parents: 22885
diff changeset
1164 %! assert (d{2} (3), 6);
22016
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
1165 %! unwind_protect_cleanup
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
1166 %! unlink (f);
26677
33f79d94f21f Create any BIST temporary files in writable temporary directory (bug #55565).
Rik <rik@octave.org>
parents: 26661
diff changeset
1167 %! path (save_path);
22016
d4ce10f57918 Clean up localfunctions BIST test
Mike Miller <mtmiller@octave.org>
parents: 21966
diff changeset
1168 %! end_unwind_protect
21765
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
1169 */
23a610a3f001 Implement localfunctions Matlab command (bug #47705).
Lachlan Andrew <lachlanbis@gmail.com>
parents: 21733
diff changeset
1170
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1171 DEFMETHOD (__which__, interp, args, ,
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1172 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30588
diff changeset
1173 @deftypefn {} {@var{var_struct} =} __which__ (@var{name}, @dots{})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1174 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
1175 @end deftypefn */)
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 572
diff changeset
1176 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
1177 help_system& help_sys = interp.get_help_system ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1178
20996
20bd3d4fabad Clean up instances of make_argv().
Rik <rik@octave.org>
parents: 20940
diff changeset
1179 string_vector argv = args.make_argv ();
1755
3a9462b655f1 [project @ 1996-01-22 04:47:22 by jwe]
jwe
parents: 1742
diff changeset
1180
20922
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
1181 int nargin = argv.numel ();
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 572
diff changeset
1182
20922
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
1183 octave_map m (dim_vector (1, nargin));
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 572
diff changeset
1184
20922
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
1185 Cell names (1, nargin);
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
1186 Cell files (1, nargin);
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
1187 Cell types (1, nargin);
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
1188
20922
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
1189 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
1190 {
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
1191 std::string name = argv[i];
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
1192
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
1193 std::string type;
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
1194
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1195 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
1196
20922
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
1197 names(i) = name;
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
1198 files(i) = file;
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
1199 types(i) = type;
20803
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
1200 }
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
1201
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
1202 m.assign ("name", names);
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
1203 m.assign ("file", files);
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
1204 m.assign ("type", types);
c22206c1a88f eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20714
diff changeset
1205
20922
49081851fddc Eliminate duplicate input arg checking in which.m and __which__.
Rik <rik@octave.org>
parents: 20884
diff changeset
1206 return ovl (m);
581
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 572
diff changeset
1207 }
bc813f5eb025 [project @ 1994-08-07 01:02:15 by jwe]
jwe
parents: 572
diff changeset
1208
8812
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8672
diff changeset
1209 // 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
1210 // 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
1211 // the current path.
7d48766c21a5 use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents: 8672
diff changeset
1212
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1213 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
1214 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
1215 @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
1216 @deftypefnx {} {@var{retval} =} __list_functions__ (@var{directory})
22337
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
1217 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
1218
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
1219 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
1220 in that directory.
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
1221 @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
1222 @end deftypefn */)
8575
f134925a1cfa m-file implementation of help system
Soren Hauberg <soren@hauberg.org>
parents: 8503
diff changeset
1223 {
8863
34a821854961 pkg.m (generate_lookfor_cache): generate a DOC file for each directory
Jason Riedy <jason@acm.org>
parents: 8861
diff changeset
1224 octave_value retval;
5447
051ddd7a6681 [project @ 2005-09-14 05:18:23 by jwe]
jwe
parents: 5399
diff changeset
1225
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
1226 load_path& lp = interp.get_load_path ();
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
1227
22337
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
1228 if (args.length () == 0)
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
1229 {
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
1230 // Get list of all functions
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
1231 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
1232 string_vector afl = interp.autoloaded_functions ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1233
22337
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
1234 retval = Cell (ffl.append (afl));
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
1235 }
20581
fd0efcdb3718 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
1236 else
5447
051ddd7a6681 [project @ 2005-09-14 05:18:23 by jwe]
jwe
parents: 5399
diff changeset
1237 {
20700
68e3a747ca02 rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents: 20678
diff changeset
1238 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
1239
23438
d24d01273bd0 eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
1240 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
1241
22337
77c209d63b75 Update __list_functions__ internal function.
Rik <rik@octave.org>
parents: 22323
diff changeset
1242 // 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
1243 // 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
1244 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
1245
20581
fd0efcdb3718 use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents: 20232
diff changeset
1246 retval = Cell (fl);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11572
diff changeset
1247 }
5447
051ddd7a6681 [project @ 2005-09-14 05:18:23 by jwe]
jwe
parents: 5399
diff changeset
1248
051ddd7a6681 [project @ 2005-09-14 05:18:23 by jwe]
jwe
parents: 5399
diff changeset
1249 return retval;
051ddd7a6681 [project @ 2005-09-14 05:18:23 by jwe]
jwe
parents: 5399
diff changeset
1250 }
051ddd7a6681 [project @ 2005-09-14 05:18:23 by jwe]
jwe
parents: 5399
diff changeset
1251
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1252 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
1253 doc: /* -*- texinfo -*-
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1254 @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
1255 @deftypefnx {} {@var{old_val} =} built_in_docstrings_file (@var{new_val})
30588
ed17822e7662 doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents: 30565
diff changeset
1256 @deftypefnx {} {@var{old_val} =} built_in_docstrings_file (@var{new_val}, "local")
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1257 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
1258 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
1259
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1260 The default value is
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1261 @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
1262 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
1263 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
1264 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
1265 @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
1266 @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
1267
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1268 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
1269 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
1270 @end deftypefn */)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1271 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
1272 help_system& help_sys = interp.get_help_system ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1273
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1274 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
1275 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1276
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1277 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
1278 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
1279 @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
1280 @deftypefnx {} {@var{old_val} =} doc_cache_file (@var{new_val})
30588
ed17822e7662 doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents: 30565
diff changeset
1281 @deftypefnx {} {@var{old_val} =} doc_cache_file (@var{new_val}, "local")
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1282 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
1283 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
1284
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1285 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
1286 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
1287 @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
1288 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
1289 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
1290 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
1291 @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
1292 @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
1293
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1294 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
1295 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
1296 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
1297 @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
1298 @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
1299 @end deftypefn */)
8861
31f864877246 doc and lookfor fixes
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
1300 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
1301 help_system& help_sys = interp.get_help_system ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1302
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1303 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
1304 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1305
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1306 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
1307 doc: /* -*- texinfo -*-
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1308 @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
1309 @deftypefnx {} {@var{old_val} =} info_file (@var{new_val})
30588
ed17822e7662 doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents: 30565
diff changeset
1310 @deftypefnx {} {@var{old_val} =} info_file (@var{new_val}, "local")
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1311 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
1312 Octave info file.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1313
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1314 The default value is
28880
68e6e6f083f3 doc: Correct some installation paths (bug #59236).
Markus Mützel <markus.muetzel@gmx.de>
parents: 28514
diff changeset
1315 @file{@var{octave-home}/share/info/octave.info}, in
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1316 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
1317 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
1318 @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
1319 @option{--info-file FNAME}.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1320
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1321 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
1322 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
1323 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
1324 @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
1325 @end deftypefn */)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1326 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
1327 help_system& help_sys = interp.get_help_system ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1328
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1329 return help_sys.info_file (args, nargout);
8861
31f864877246 doc and lookfor fixes
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
1330 }
31f864877246 doc and lookfor fixes
John W. Eaton <jwe@octave.org>
parents: 8812
diff changeset
1331
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1332 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
1333 doc: /* -*- texinfo -*-
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1334 @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
1335 @deftypefnx {} {@var{old_val} =} info_program (@var{new_val})
30588
ed17822e7662 doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents: 30565
diff changeset
1336 @deftypefnx {} {@var{old_val} =} info_program (@var{new_val}, "local")
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1337 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
1338 info program to run.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1339
29668
f17b1f0141ed doc: Grammarcheck documentation ahead of 6.3 release.
Rik <rik@octave.org>
parents: 29654
diff changeset
1340 The default value is @file{info}. The default value may be
f17b1f0141ed doc: Grammarcheck documentation ahead of 6.3 release.
Rik <rik@octave.org>
parents: 29654
diff changeset
1341 overridden by the environment variable @w{@env{OCTAVE_INFO_PROGRAM}}, or the
f17b1f0141ed doc: Grammarcheck documentation ahead of 6.3 release.
Rik <rik@octave.org>
parents: 29654
diff changeset
1342 command line argument @option{--info-program NAME}.
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1343
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1344 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
1345 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
1346 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
1347 @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
1348 @end deftypefn */)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1349 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
1350 help_system& help_sys = interp.get_help_system ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1351
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1352 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
1353 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1354
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1355 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
1356 doc: /* -*- texinfo -*-
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1357 @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
1358 @deftypefnx {} {@var{old_val} =} makeinfo_program (@var{new_val})
30588
ed17822e7662 doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents: 30565
diff changeset
1359 @deftypefnx {} {@var{old_val} =} makeinfo_program (@var{new_val}, "local")
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1360 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
1361 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
1362 Texinfo markup commands.
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1363
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1364 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
1365
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1366 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
1367 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
1368 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
1369 @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
1370 @end deftypefn */)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1371 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
1372 help_system& help_sys = interp.get_help_system ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1373
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1374 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
1375 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1376
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1377 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
1378 doc: /* -*- texinfo -*-
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1379 @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
1380 @deftypefnx {} {@var{old_val} =} suppress_verbose_help_message (@var{new_val})
30588
ed17822e7662 doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents: 30565
diff changeset
1381 @deftypefnx {} {@var{old_val} =} suppress_verbose_help_message (@var{new_val}, "local")
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1382 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
1383 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
1384 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
1385
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1386 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
1387 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
1388 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
1389 @end deftypefn */)
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1390 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
1391 help_system& help_sys = interp.get_help_system ();
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1392
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1393 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
1394 }
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1395
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1396 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
1397 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
1398 @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
1399 @deftypefnx {} {@var{old_val} =} texi_macros_file (@var{new_val})
30588
ed17822e7662 doc: Always have a return value for functions which set internal variables (bug #61681)
Rik <rik@octave.org>
parents: 30565
diff changeset
1400 @deftypefnx {} {@var{old_val} =} texi_macros_file (@var{new_val}, "local")
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1401 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
1402 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
1403 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
1404
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1405 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
1406 @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
1407 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
1408 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
1409 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
1410 @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
1411 @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
1412
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21921
diff changeset
1413 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
1414 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
1415 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
1416 @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
1417 @end deftypefn */)
14614
4e9dc46d4125 handle texinfo macros consistently in help system and manual
John W. Eaton <jwe@octave.org>
parents: 14360
diff changeset
1418 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29960
diff changeset
1419 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
1420
23721
b2d55b52ee51 new class to manage help system and associated variables
John W. Eaton <jwe@octave.org>
parents: 23693
diff changeset
1421 return help_sys.texi_macros_file (args, nargout);
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5780
diff changeset
1422 }
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29670
diff changeset
1423
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 31105
diff changeset
1424 OCTAVE_END_NAMESPACE(octave)