File: help.h

package info (click to toggle)
octave 6.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 124,192 kB
  • sloc: cpp: 322,665; ansic: 68,088; fortran: 20,980; objc: 8,121; sh: 7,719; yacc: 4,266; lex: 4,123; perl: 1,530; java: 1,366; awk: 1,257; makefile: 424; xml: 147
file content (207 lines) | stat: -rw-r--r-- 6,173 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 1993-2021 The Octave Project Developers
//
// See the file COPYRIGHT.md in the top-level directory of this
// distribution or <https://octave.org/copyright/>.
//
// This file is part of Octave.
//
// Octave is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Octave is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Octave; see the file COPYING.  If not, see
// <https://www.gnu.org/licenses/>.
//
////////////////////////////////////////////////////////////////////////

#if ! defined (octave_help_h)
#define octave_help_h 1

#include "octave-config.h"

#include <iosfwd>
#include <string>

class string_vector;

class octave_value;
class octave_value_list;

namespace octave
{
  class interpreter;

  class help_system
  {
  public:

    help_system (interpreter& interp)
      : m_interpreter (interp),
        m_built_in_docstrings_file (init_built_in_docstrings_file ()),
        m_doc_cache_file (init_doc_cache_file ()),
        m_info_file (init_info_file ()),
        m_info_program (init_info_program ()),
        m_makeinfo_program ("makeinfo"),
        m_suppress_verbose_help_message (false),
        m_texi_macros_file (init_texi_macros_file ())
    { }

    octave_value
    built_in_docstrings_file (const octave_value_list& args, int nargout);

    std::string
    built_in_docstrings_file (void) const { return m_built_in_docstrings_file; }

    std::string built_in_docstrings_file (const std::string& file)
    {
      return set (m_built_in_docstrings_file, file);
    }

    octave_value doc_cache_file (const octave_value_list& args, int nargout);

    std::string doc_cache_file (void) const { return m_doc_cache_file; }

    std::string doc_cache_file (const std::string& file)
    {
      return set (m_doc_cache_file, file);
    }

    octave_value info_file (const octave_value_list& args, int nargout);

    std::string info_file (void) const { return m_info_file; }

    std::string info_file (const std::string& file)
    {
      return set (m_info_file, file);
    }

    octave_value info_program (const octave_value_list& args, int nargout);

    std::string info_program (void) const { return m_info_program; }

    std::string info_program (const std::string& file)
    {
      return set (m_info_program, file);
    }

    octave_value makeinfo_program (const octave_value_list& args, int nargout);

    std::string makeinfo_program (void) const { return m_makeinfo_program; }

    std::string makeinfo_program (const std::string& file)
    {
      return set (m_makeinfo_program, file);
    }

    octave_value
    suppress_verbose_help_message (const octave_value_list& args, int nargout);

    bool suppress_verbose_help_message (void) const
    {
      return m_suppress_verbose_help_message;
    }

    bool suppress_verbose_help_message (bool flag)
    {
      return set (m_suppress_verbose_help_message, flag);
    }

    octave_value texi_macros_file (const octave_value_list& args, int nargout);

    std::string texi_macros_file (void) const { return m_texi_macros_file; }

    std::string texi_macros_file (const std::string& file)
    {
      return set (m_texi_macros_file, file);
    }

    std::string raw_help (const std::string&, bool&) const;

    std::string which (const std::string& name) const;
    std::string which (const std::string& name, std::string& type) const;

    string_vector make_name_list (void) const;

    void get_help_text (const std::string& name, std::string& text,
                        std::string& format) const;

    void get_help_text_from_file (const std::string& fname, std::string& text,
                                  std::string& format) const;

  private:

    interpreter& m_interpreter;

    // Name of the file containing doc strings for built-in functions.
    // (--built-in-docstrings-file file)
    std::string m_built_in_docstrings_file;

    // Name of the doc cache file specified on the command line.
    // (--doc-cache-file file)
    std::string m_doc_cache_file;

    // Name of the info file specified on command line.
    // (--info-file file)
    std::string m_info_file;

    // Name of the info reader we'd like to use.
    // (--info-program program)
    std::string m_info_program;

    // Name of the makeinfo program to run.
    std::string m_makeinfo_program;

    // If TRUE, don't print additional help message in help and usage
    // functions.
    bool m_suppress_verbose_help_message;

    // Name of the file containing local Texinfo macros that are prepended
    // to doc strings before processing.
    // (--texi-macros-file)
    std::string m_texi_macros_file;

    static std::string init_built_in_docstrings_file (void);

    static std::string init_doc_cache_file (void);

    static std::string init_info_file (void);

    static std::string init_info_program (void);

    static std::string init_texi_macros_file (void);

    template <typename T>
    T set (T& var, const T& new_val)
    {
      T old_val = var;
      var = new_val;
      return old_val;
    }

    string_vector local_functions (void) const;

    bool raw_help_from_symbol_table (const std::string& nm,
                                     std::string& h, std::string& w,
                                     bool& symbol_found) const;

    bool raw_help_from_file (const std::string& nm,
                             std::string& h, std::string& file,
                             bool& symbol_found) const;

    bool raw_help_from_docstrings_file (const std::string& nm, std::string& h,
                                        bool& symbol_found) const;
  };

  extern string_vector make_name_list (void);
}

#endif