GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
help.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1993-2021 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 
39 namespace octave
40 {
41  class interpreter;
42 
44  {
45  public:
46 
48  : m_interpreter (interp),
53  m_makeinfo_program ("makeinfo"),
56  { }
57 
59  built_in_docstrings_file (const octave_value_list& args, int nargout);
60 
61  std::string
63 
64  std::string built_in_docstrings_file (const std::string& file)
65  {
66  return set (m_built_in_docstrings_file, file);
67  }
68 
69  octave_value doc_cache_file (const octave_value_list& args, int nargout);
70 
71  std::string doc_cache_file (void) const { return m_doc_cache_file; }
72 
73  std::string doc_cache_file (const std::string& file)
74  {
75  return set (m_doc_cache_file, file);
76  }
77 
78  octave_value info_file (const octave_value_list& args, int nargout);
79 
80  std::string info_file (void) const { return m_info_file; }
81 
82  std::string info_file (const std::string& file)
83  {
84  return set (m_info_file, file);
85  }
86 
87  octave_value info_program (const octave_value_list& args, int nargout);
88 
89  std::string info_program (void) const { return m_info_program; }
90 
91  std::string info_program (const std::string& file)
92  {
93  return set (m_info_program, file);
94  }
95 
96  octave_value makeinfo_program (const octave_value_list& args, int nargout);
97 
98  std::string makeinfo_program (void) const { return m_makeinfo_program; }
99 
100  std::string makeinfo_program (const std::string& file)
101  {
102  return set (m_makeinfo_program, file);
103  }
104 
107 
109  {
111  }
112 
114  {
115  return set (m_suppress_verbose_help_message, flag);
116  }
117 
118  octave_value texi_macros_file (const octave_value_list& args, int nargout);
119 
120  std::string texi_macros_file (void) const { return m_texi_macros_file; }
121 
122  std::string texi_macros_file (const std::string& file)
123  {
124  return set (m_texi_macros_file, file);
125  }
126 
127  std::string raw_help (const std::string&, bool&) const;
128 
129  std::string which (const std::string& name) const;
130  std::string which (const std::string& name, std::string& type) const;
131 
133 
134  void get_help_text (const std::string& name, std::string& text,
135  std::string& format) const;
136 
137  void get_help_text_from_file (const std::string& fname, std::string& text,
138  std::string& format) const;
139 
140  private:
141 
143 
144  // Name of the file containing doc strings for built-in functions.
145  // (--built-in-docstrings-file file)
147 
148  // Name of the doc cache file specified on the command line.
149  // (--doc-cache-file file)
150  std::string m_doc_cache_file;
151 
152  // Name of the info file specified on command line.
153  // (--info-file file)
154  std::string m_info_file;
155 
156  // Name of the info reader we'd like to use.
157  // (--info-program program)
158  std::string m_info_program;
159 
160  // Name of the makeinfo program to run.
161  std::string m_makeinfo_program;
162 
163  // If TRUE, don't print additional help message in help and usage
164  // functions.
166 
167  // Name of the file containing local Texinfo macros that are prepended
168  // to doc strings before processing.
169  // (--texi-macros-file)
170  std::string m_texi_macros_file;
171 
172  static std::string init_built_in_docstrings_file (void);
173 
174  static std::string init_doc_cache_file (void);
175 
176  static std::string init_info_file (void);
177 
178  static std::string init_info_program (void);
179 
180  static std::string init_texi_macros_file (void);
181 
182  template <typename T>
183  T set (T& var, const T& new_val)
184  {
185  T old_val = var;
186  var = new_val;
187  return old_val;
188  }
189 
191 
192  bool raw_help_from_symbol_table (const std::string& nm,
193  std::string& h, std::string& w,
194  bool& symbol_found) const;
195 
196  bool raw_help_from_file (const std::string& nm,
197  std::string& h, std::string& file,
198  bool& symbol_found) const;
199 
200  bool raw_help_from_docstrings_file (const std::string& nm, std::string& h,
201  bool& symbol_found) const;
202  };
203 
205 }
206 
207 #endif
std::string raw_help(const std::string &, bool &) const
octave_value info_program(const octave_value_list &args, int nargout)
T set(T &var, const T &new_val)
Definition: help.h:183
std::string info_file(const std::string &file)
Definition: help.h:82
octave_value info_file(const octave_value_list &args, int nargout)
static std::string init_doc_cache_file(void)
std::string m_doc_cache_file
Definition: help.h:150
std::string makeinfo_program(void) const
Definition: help.h:98
octave_value texi_macros_file(const octave_value_list &args, int nargout)
std::string texi_macros_file(const std::string &file)
Definition: help.h:122
bool suppress_verbose_help_message(void) const
Definition: help.h:108
std::string doc_cache_file(void) const
Definition: help.h:71
bool raw_help_from_symbol_table(const std::string &nm, std::string &h, std::string &w, bool &symbol_found) const
interpreter & m_interpreter
Definition: help.h:142
bool m_suppress_verbose_help_message
Definition: help.h:165
std::string built_in_docstrings_file(void) const
Definition: help.h:62
string_vector make_name_list(void) const
std::string info_program(void) const
Definition: help.h:89
std::string built_in_docstrings_file(const std::string &file)
Definition: help.h:64
std::string which(const std::string &name, std::string &type) const
std::string m_built_in_docstrings_file
Definition: help.h:146
bool raw_help_from_file(const std::string &nm, std::string &h, std::string &file, bool &symbol_found) const
octave_value suppress_verbose_help_message(const octave_value_list &args, int nargout)
string_vector local_functions(void) const
bool raw_help_from_docstrings_file(const std::string &nm, std::string &h, bool &symbol_found) const
std::string m_texi_macros_file
Definition: help.h:170
octave_value makeinfo_program(const octave_value_list &args, int nargout)
std::string info_program(const std::string &file)
Definition: help.h:91
std::string makeinfo_program(const std::string &file)
Definition: help.h:100
std::string info_file(void) const
Definition: help.h:80
octave_value built_in_docstrings_file(const octave_value_list &args, int nargout)
static std::string init_info_file(void)
std::string doc_cache_file(const std::string &file)
Definition: help.h:73
static std::string init_texi_macros_file(void)
std::string m_info_file
Definition: help.h:154
std::string texi_macros_file(void) const
Definition: help.h:120
std::string m_info_program
Definition: help.h:158
std::string m_makeinfo_program
Definition: help.h:161
help_system(interpreter &interp)
Definition: help.h:47
std::string which(const std::string &name) const
void get_help_text_from_file(const std::string &fname, std::string &text, std::string &format) const
static std::string init_info_program(void)
void get_help_text(const std::string &name, std::string &text, std::string &format) const
bool suppress_verbose_help_message(bool flag)
Definition: help.h:113
octave_value doc_cache_file(const octave_value_list &args, int nargout)
static std::string init_built_in_docstrings_file(void)
QString name
std::complex< double > w(std::complex< double > z, double relerr=0)
string_vector make_name_list(void)
size_t format(std::ostream &os, const char *fmt,...)
Definition: utils.cc:1329