GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
help.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1993-2024 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_help_h)
27 #define octave_help_h 1
28 
29 #include "octave-config.h"
30 
31 #include <iosfwd>
32 #include <string>
33 
34 class string_vector;
35 
36 class octave_value;
37 class octave_value_list;
38 
40 
41 class cdef_class;
42 class interpreter;
43 
45 {
46 public:
47 
49  : m_interpreter (interp),
50  m_built_in_docstrings_file (init_built_in_docstrings_file ()),
51  m_doc_cache_file (init_doc_cache_file ()),
52  m_info_file (init_info_file ()),
53  m_info_program (init_info_program ()),
54  m_makeinfo_program ("makeinfo"),
55  m_suppress_verbose_help_message (false),
56  m_texi_macros_file (init_texi_macros_file ())
57  { }
58 
60  built_in_docstrings_file (const octave_value_list& args, int nargout);
61 
62  std::string
63  built_in_docstrings_file () const { return m_built_in_docstrings_file; }
64 
65  std::string built_in_docstrings_file (const std::string& file)
66  {
67  return set (m_built_in_docstrings_file, file);
68  }
69 
70  octave_value doc_cache_file (const octave_value_list& args, int nargout);
71 
72  std::string doc_cache_file () const { return m_doc_cache_file; }
73 
74  std::string doc_cache_file (const std::string& file)
75  {
76  return set (m_doc_cache_file, file);
77  }
78 
79  octave_value info_file (const octave_value_list& args, int nargout);
80 
81  std::string info_file () const { return m_info_file; }
82 
83  std::string info_file (const std::string& file)
84  {
85  return set (m_info_file, file);
86  }
87 
88  octave_value info_program (const octave_value_list& args, int nargout);
89 
90  std::string info_program () const { return m_info_program; }
91 
92  std::string info_program (const std::string& file)
93  {
94  return set (m_info_program, file);
95  }
96 
97  octave_value makeinfo_program (const octave_value_list& args, int nargout);
98 
99  std::string makeinfo_program () const { return m_makeinfo_program; }
100 
101  std::string makeinfo_program (const std::string& file)
102  {
103  return set (m_makeinfo_program, file);
104  }
105 
108 
110  {
111  return m_suppress_verbose_help_message;
112  }
113 
115  {
116  return set (m_suppress_verbose_help_message, flag);
117  }
118 
119  octave_value texi_macros_file (const octave_value_list& args, int nargout);
120 
121  std::string texi_macros_file () const { return m_texi_macros_file; }
122 
123  std::string texi_macros_file (const std::string& file)
124  {
125  return set (m_texi_macros_file, file);
126  }
127 
128  std::string raw_help (const std::string&, bool&) const;
129 
130  std::string which (const std::string& name) const;
131  std::string which (const std::string& name, std::string& type) const;
132 
134 
135  void get_help_text (const std::string& name, std::string& text,
136  std::string& format) const;
137 
138  void get_help_text_from_file (const std::string& fname, std::string& text,
139  std::string& format) const;
140 
141 private:
142 
143  interpreter& m_interpreter;
144 
145  // Name of the file containing doc strings for built-in functions.
146  // (--built-in-docstrings-file file)
147  std::string m_built_in_docstrings_file;
148 
149  // Name of the doc cache file specified on the command line.
150  // (--doc-cache-file file)
151  std::string m_doc_cache_file;
152 
153  // Name of the info file specified on command line.
154  // (--info-file file)
155  std::string m_info_file;
156 
157  // Name of the info reader we'd like to use.
158  // (--info-program program)
159  std::string m_info_program;
160 
161  // Name of the makeinfo program to run.
162  std::string m_makeinfo_program;
163 
164  // If TRUE, don't print additional help message in help and usage
165  // functions.
166  bool m_suppress_verbose_help_message;
167 
168  // Name of the file containing local Texinfo macros that are prepended
169  // to doc strings before processing.
170  // (--texi-macros-file)
171  std::string m_texi_macros_file;
172 
173  static std::string init_built_in_docstrings_file ();
174 
175  static std::string init_doc_cache_file ();
176 
177  static std::string init_info_file ();
178 
179  static std::string init_info_program ();
180 
181  static std::string init_texi_macros_file ();
182 
183  template <typename T>
184  T set (T& var, const T& new_val)
185  {
186  T old_val = var;
187  var = new_val;
188  return old_val;
189  }
190 
191  bool get_which_info_from_fcn (const std::string& name, const octave_value& ov_fcn, std::string& file, std::string& type) const;
192 
193  string_vector local_functions () const;
194 
195  bool raw_help_for_class (const cdef_class& cls, const std::string& nm,
196  std::string& h, std::string& w,
197  bool& symbol_found) const;
198 
199  bool raw_help_from_symbol_table (const std::string& nm,
200  std::string& h, std::string& w,
201  bool& symbol_found) const;
202 
203  bool raw_help_from_file (const std::string& nm,
204  std::string& h, std::string& file,
205  bool& symbol_found) const;
206 
207  bool raw_help_from_docstrings_file (const std::string& nm, std::string& h,
208  bool& symbol_found) const;
209 };
210 
212 
213 OCTAVE_END_NAMESPACE(octave)
214 
215 #endif
string_vector make_name_list() const
std::string texi_macros_file() const
Definition: help.h:121
void get_help_text_from_file(const std::string &fname, std::string &text, std::string &format) const
std::string makeinfo_program(const std::string &file)
Definition: help.h:101
void get_help_text(const std::string &name, std::string &text, std::string &format) const
octave_value built_in_docstrings_file(const octave_value_list &args, int nargout)
std::string raw_help(const std::string &, bool &) const
bool suppress_verbose_help_message(bool flag)
Definition: help.h:114
std::string info_file() const
Definition: help.h:81
std::string info_program() const
Definition: help.h:90
bool suppress_verbose_help_message() const
Definition: help.h:109
std::string which(const std::string &name) const
octave_value info_file(const octave_value_list &args, int nargout)
std::string info_program(const std::string &file)
Definition: help.h:92
std::string which(const std::string &name, std::string &type) const
std::string texi_macros_file(const std::string &file)
Definition: help.h:123
help_system(interpreter &interp)
Definition: help.h:48
octave_value info_program(const octave_value_list &args, int nargout)
std::string built_in_docstrings_file(const std::string &file)
Definition: help.h:65
std::string built_in_docstrings_file() const
Definition: help.h:63
octave_value suppress_verbose_help_message(const octave_value_list &args, int nargout)
std::string doc_cache_file() const
Definition: help.h:72
octave_value doc_cache_file(const octave_value_list &args, int nargout)
std::string makeinfo_program() const
Definition: help.h:99
std::string info_file(const std::string &file)
Definition: help.h:83
std::string doc_cache_file(const std::string &file)
Definition: help.h:74
octave_value makeinfo_program(const octave_value_list &args, int nargout)
octave_value texi_macros_file(const octave_value_list &args, int nargout)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
string_vector make_name_list()
std::complex< double > w(std::complex< double > z, double relerr=0)
std::size_t format(std::ostream &os, const char *fmt,...)