GNU Octave 7.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
help.cc
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1993-2022 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 (HAVE_CONFIG_H)
27# include "config.h"
28#endif
29
30#include <cstdlib>
31#include <cstring>
32
33#include <algorithm>
34#include <fstream>
35#include <istream>
36#include <map>
37#include <sstream>
38#include <string>
39
40#include "cmd-edit.h"
41#include "file-ops.h"
42#include "file-stat.h"
43#include "lo-sysdep.h"
44#include "oct-env.h"
45#include "oct-locbuf.h"
46#include "str-vec.h"
47
48#include "Cell.h"
49#include "builtin-defun-decls.h"
50#include "defaults.h"
51#include "defun.h"
52#include "error.h"
53#include "errwarn.h"
54#include "help.h"
55#include "input.h"
56#include "interpreter-private.h"
57#include "interpreter.h"
58#include "load-path.h"
59#include "ov-classdef.h"
60#include "ov-fcn-handle.h"
61#include "ov-usr-fcn.h"
62#include "ovl.h"
63#include "pager.h"
64#include "parse.h"
65#include "pathsearch.h"
66#include "procstream.h"
67#include "quit.h"
68#include "sighandlers.h"
69#include "symtab.h"
70#include "unwind-prot.h"
71#include "utils.h"
72#include "variables.h"
73#include "version.h"
74
75#include "default-defs.h"
76
77OCTAVE_NAMESPACE_BEGIN
78
79 const static char * const operators[] =
80 {
81 "!",
82 "~",
83 "!=",
84 "~=",
85 R"(")",
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 R"(.\)",
111 R"(\)",
112 ":",
113 ";",
114 "<",
115 "<=",
116 "=",
117 "==",
118 ">",
119 ">=",
120 "[",
121 "]",
122 "|",
123 "||",
124 nullptr
125 };
126
127 const static string_vector operator_names (operators);
128
129 static bool
130 looks_like_html (const std::string& msg)
131 {
132 const std::size_t p1 = msg.find ('\n');
133 std::string t = msg.substr (0, p1);
134 // FIXME: this comparison should be case-insensitive
135 const std::size_t p2 = t.find ("<html");
136
137 return (p2 != std::string::npos);
138 }
139
140 static bool
141 looks_like_texinfo (const std::string& msg, std::size_t& p1)
142 {
143 p1 = msg.find ('\n');
144
145 std::string t = msg.substr (0, p1);
146
147 if (p1 == std::string::npos)
148 p1 = 0;
149
150 std::size_t p2 = t.find ("-*- texinfo -*-");
151
152 return (p2 != std::string::npos);
153 }
154
157 int nargout)
158 {
160 "built_in_docstrings_file", false);
161 }
162
164 help_system::doc_cache_file (const octave_value_list& args, int nargout)
165 {
166 return set_internal_variable (m_doc_cache_file, args, nargout,
167 "doc_cache_file", false);
168 }
169
171 help_system::info_file (const octave_value_list& args, int nargout)
172 {
173 return set_internal_variable (m_info_file, args, nargout,
174 "info_file", false);
175 }
176
178 help_system::info_program (const octave_value_list& args, int nargout)
179 {
180 return set_internal_variable (m_info_program, args, nargout,
181 "info_program", false);
182 }
183
185 help_system::makeinfo_program (const octave_value_list& args, int nargout)
186 {
187 return set_internal_variable (m_makeinfo_program, args, nargout,
188 "makeinfo_program", false);
189 }
190
193 int nargout)
194 {
196 nargout, "suppress_verbose_help_message");
197 }
198
200 help_system::texi_macros_file (const octave_value_list& args, int nargout)
201 {
202 return set_internal_variable (m_texi_macros_file, args, nargout,
203 "texi_macros_file", false);
204 }
205
206 std::string
207 help_system::raw_help (const std::string& nm, bool& symbol_found) const
208 {
209 std::string h;
210 std::string w;
211 std::string f;
212
213 bool found;
214
215 found = raw_help_from_symbol_table (nm, h, w, symbol_found);
216
217 if (! found)
218 found = raw_help_from_file (nm, h, f, symbol_found);
219
220 bool external_doc = h.compare (0, 12, "external-doc") == 0;
221
222 if (! found || external_doc)
223 {
224 std::string tmp_nm = nm;
225
226 if (external_doc && h.length () > 12 && h[12] == ':')
227 tmp_nm = h.substr (13);
228
229 raw_help_from_docstrings_file (tmp_nm, h, symbol_found);
230 }
231
232 return h;
233 }
234
235 std::string help_system::which (const std::string& name,
236 std::string& type) const
237 {
238 std::string file;
239
240 if (name.empty ())
241 return file;
242
243 type = "";
244
246
247 octave_value val = symtab.find_function (name);
248
249 if (val.is_defined ())
250 {
251 octave_function *fcn = val.function_value ();
252
253 if (fcn)
254 {
255 if (fcn->is_classdef_meta ())
256 {
257 octave_classdef_meta *meta_obj
258 = dynamic_cast<octave_classdef_meta *> (fcn);
259
260 file = meta_obj->file_name ();
261
262 if (meta_obj->is_classdef_constructor ())
263 type = "class constructor";
264 else if (meta_obj->is_classdef_method ())
265 type = "class method";
266 else
267 type = "classdef meta object";
268 }
269 else
270 {
271
272 file = fcn->fcn_file_name ();
273
274 if (! file.empty ())
275 type = val.is_user_script () ? "script" : "function";
276 else
277 {
278 if (fcn->is_user_function ())
279 type = "command-line function";
280 else
281 {
282 file = fcn->src_file_name ();
283 type = "built-in function";
284 }
285 }
286 }
287 }
288 else
289 {
290 // We might find a file that contains only a doc string.
291
293
294 file = lp.find_fcn_file (name);
295 }
296 }
297
298 if (file.empty ())
299 {
300 // File query.
301
303
304 // For compatibility: "file." queries "file".
305 if (name.size () > 1 && name[name.size () - 1] == '.')
306 file = lp.find_file (name.substr (0, name.size () - 1));
307 else
308 file = lp.find_file (name);
309
310 file = sys::env::make_absolute (file);
311 }
312
313 return file;
314 }
315
316 std::string help_system::which (const std::string& name) const
317 {
318 std::string type;
319
320 return which (name, type);
321 }
322
324 {
325 const static string_vector keywords
326 = Fiskeyword ()(0).string_vector_value ();
327
328 const static int key_len = keywords.numel ();
329
331
332 const string_vector bif = symtab.built_in_function_names ();
333 const int bif_len = bif.numel ();
334
335 const string_vector cfl = symtab.cmdline_function_names ();
336 const int cfl_len = cfl.numel ();
337
339 const int lcl_len = lcl.numel ();
340
342
343 const string_vector ffl = lp.fcn_names ();
344 const int ffl_len = ffl.numel ();
345
347 const int afl_len = afl.numel ();
348
349 const string_vector lfl = local_functions ();
350 const int lfl_len = lfl.numel ();
351
352 const int total_len
353 = key_len + bif_len + cfl_len + lcl_len + ffl_len + afl_len + lfl_len;
354
355 string_vector list (total_len);
356
357 // Put all the symbols in one big list.
358
359 int j = 0;
360 int i = 0;
361
362 for (i = 0; i < key_len; i++)
363 list[j++] = keywords[i];
364
365 for (i = 0; i < bif_len; i++)
366 list[j++] = bif[i];
367
368 for (i = 0; i < cfl_len; i++)
369 list[j++] = cfl[i];
370
371 for (i = 0; i < lcl_len; i++)
372 list[j++] = lcl[i];
373
374 for (i = 0; i < ffl_len; i++)
375 list[j++] = ffl[i];
376
377 for (i = 0; i < afl_len; i++)
378 list[j++] = afl[i];
379
380 for (i = 0; i < lfl_len; i++)
381 list[j++] = lfl[i];
382
383 return list;
384 }
385
386 void help_system::get_help_text (const std::string& name, std::string& text,
387 std::string& format) const
388 {
389 bool symbol_found = false;
390 text = raw_help (name, symbol_found);
391
392 format = "Not found";
393 if (symbol_found)
394 {
395 std::size_t idx = -1;
396 if (text.empty ())
397 {
398 format = "Not documented";
399 }
400 else if (looks_like_texinfo (text, idx))
401 {
402 format = "texinfo";
403 text.erase (0, idx);
404 }
405 else if (looks_like_html (text))
406 {
407 format = "html";
408 }
409 else
410 {
411 format = "plain text";
412 }
413 }
414 }
415
416 void help_system::get_help_text_from_file (const std::string& fname,
417 std::string& text,
418 std::string& format) const
419 {
420 bool symbol_found = false;
421
422 std::string f;
423
424 raw_help_from_file (fname, text, f, symbol_found);
425
426 format = "Not found";
427 if (symbol_found)
428 {
429 std::size_t idx = -1;
430 if (text.empty ())
431 {
432 format = "Not documented";
433 }
434 else if (looks_like_texinfo (text, idx))
435 {
436 format = "texinfo";
437 text.erase (0, idx);
438 }
439 else if (looks_like_html (text))
440 {
441 format = "html";
442 }
443 else
444 {
445 format = "plain text";
446 }
447 }
448 }
449
451 {
452 std::string df = sys::env::getenv ("OCTAVE_BUILT_IN_DOCSTRINGS_FILE");
453
454 std::string dir_sep = sys::file_ops::dir_sep_str ();
455
456 if (df.empty ())
457 df = config::oct_etc_dir () + dir_sep + "built-in-docstrings";
458
459 return df;
460 }
461
462 std::string help_system::init_doc_cache_file (void)
463 {
464 std::string def_file = config::prepend_octave_home (OCTAVE_DOC_CACHE_FILE);
465
466 std::string env_file = sys::env::getenv ("OCTAVE_DOC_CACHE_FILE");
467
468 return (env_file.empty () ? def_file : env_file);
469 }
470
471 std::string help_system::init_info_file (void)
472 {
473 std::string std_info_file = config::prepend_octave_home (OCTAVE_INFOFILE);
474
475 std::string oct_info_file = sys::env::getenv ("OCTAVE_INFO_FILE");
476
477 return (oct_info_file.empty () ? std_info_file : oct_info_file);
478 }
479
480 std::string help_system::init_info_program (void)
481 {
482 std::string info_prog = sys::env::getenv ("OCTAVE_INFO_PROGRAM");
483
484 if (info_prog.empty ())
485 info_prog = "info";
486
487 return info_prog;
488 }
489
490 std::string help_system::init_texi_macros_file (void)
491 {
492 std::string def_file
493 = config::prepend_octave_home (OCTAVE_TEXI_MACROS_FILE);
494
495 std::string env_file = sys::env::getenv ("OCTAVE_TEXI_MACROS_FILE");
496
497 return (env_file.empty () ? def_file : env_file);
498 }
499
500 // Return a vector of all functions from this file,
501 // for use in command line auto-completion.
503 {
504 string_vector retval;
505
507
508 octave_user_code *curr_fcn = tw.current_user_code ();
509
510 if (! curr_fcn)
511 return retval;
512
513 // All subfunctions are listed in the top-level function of this file.
514 // If curr_fcn is a subfunction, then there must be a parent and
515 // curr_fcn will always be valid in and after executing this loop.
516
517 while (curr_fcn->is_subfunction ())
518 {
519 symbol_scope pscope = curr_fcn->parent_fcn_scope ();
520 curr_fcn = pscope.user_code ();
521 }
522
523 // Get subfunctions.
524 const std::list<std::string> names = curr_fcn->subfunction_names ();
525
526 std::size_t sz = names.size ();
527 retval.resize (sz);
528
529 // Loop over them.
530 std::size_t i = 0;
531 for (const auto& nm : names)
532 retval(i++) = nm;
533
534 return retval;
535 }
536
537 bool help_system::raw_help_from_symbol_table (const std::string& nm,
538 std::string& h, std::string& w,
539 bool& symbol_found) const
540 {
541 std::string meth_nm;
542
544
545 octave_value val = symtab.find_function (nm);
546
547 if (! val.is_defined ())
548 {
549 std::size_t pos = nm.rfind ('.');
550
551 if (pos != std::string::npos)
552 {
553 meth_nm = nm.substr (pos+1);
554
555 val = symtab.find_function (nm.substr (0, pos));
556 }
557 }
558
559 if (val.is_defined ())
560 {
561 octave_function *fcn = val.function_value ();
562
563 if (fcn)
564 {
565 // FCN may actually be a classdef_meta object.
566
567 symbol_found = true;
568
569 h = fcn->doc_string (meth_nm);
570
571 w = fcn->fcn_file_name ();
572
573 if (w.empty ())
574 w = fcn->is_user_function () ? "command-line function"
575 : "built-in function";
576
577 return true;
578 }
579 }
580
581 return false;
582 }
583
584 bool help_system::raw_help_from_file (const std::string& nm,
585 std::string& h, std::string& file,
586 bool& symbol_found) const
587 {
588 bool retval = false;
589
590 h = get_help_from_file (nm, symbol_found, file);
591
592 if (h.length () > 0)
593 retval = true;
594
595 return retval;
596 }
597
598 bool
599 help_system::raw_help_from_docstrings_file (const std::string& nm,
600 std::string& h,
601 bool& symbol_found) const
602 {
603 typedef std::pair<std::streampos, std::streamoff> txt_limits_type;
604 typedef std::map<std::string, txt_limits_type> help_txt_map_type;
605
606 static help_txt_map_type help_txt_map;
607 static bool initialized = false;
608
609 h = "";
610 symbol_found = false;
611
612 // FIXME: Should we cache the timestamp of the file and reload the
613 // offsets if it changes? Or just warn about that? Or just ignore
614 // it, and assume it won't change?
615
616 if (! initialized)
617 {
619 std::ios::in | std::ios::binary);
620
621 if (! file)
622 error ("failed to open docstrings file: %s",
624
625 // Ignore header;
626 file.ignore (std::numeric_limits<std::streamsize>::max(), 0x1d);
627
628 if (file.eof ())
629 error ("invalid built-in-docstrings file!");
630
631 // FIXME: eliminate fixed buffer size.
632 std::size_t bufsize = 1000;
633 OCTAVE_LOCAL_BUFFER (char, buf, bufsize);
634
635 while (! file.eof ())
636 {
637 std::string name;
638 int i = 0;
639 int c;
640 while (file && (c = file.get ()) != std::istream::traits_type::eof ())
641 {
642 if (c == '\n' || c == '\r')
643 {
644 buf[i] = '\0';
645 name = buf;
646 break;
647 }
648 else
649 buf[i++] = c;
650 }
651
652 // Skip @c FILENAME which is part of current DOCSTRINGS
653 // syntax. This may disappear if a specific format for
654 // docstring files is developed.
655 while (file
656 && (c = file.get ()) != std::istream::traits_type::eof ()
657 && c != '\n' && c != '\r')
658 ; // skip text
659
660 // skip newline characters
661 while (file
662 && (c = file.get ()) != std::istream::traits_type::eof ()
663 && (c == '\n' || c == '\r'))
664 ; // skip text
665
666 file.unget ();
667
668 // Position of beginning of help text.
669 std::streampos beg = file.tellg ();
670
671 // Skip help text.
672 file.ignore (std::numeric_limits<std::streamsize>::max(), 0x1d);
673
674 // Position of end of help text.
675 std::streamoff len;
676
677 if (! file.eof ())
678 len = file.tellg () - beg - 1;
679 else
680 {
681 file.seekg (0, file.end);
682 len = file.tellg () - beg - 1;
683 file.setstate (file.eofbit); // reset eof flag
684 }
685
686 help_txt_map[name] = txt_limits_type (beg, len);
687 }
688
689 initialized = true;
690 }
691
692 help_txt_map_type::const_iterator it = help_txt_map.find (nm);
693
694 if (it != help_txt_map.end ())
695 {
696 txt_limits_type txt_limits = it->second;
697
698 std::streampos beg = txt_limits.first;
699 std::streamoff len = txt_limits.second;
700
702 std::ios::in | std::ios::binary);
703
704 if (! file)
705 error ("failed to open docstrings file: %s",
707
708 file.seekg (beg);
709
710 std::size_t txt_len = len;
711 OCTAVE_LOCAL_BUFFER (char, buf, txt_len + 1);
712
713 file.read (buf, txt_len);
714
715 buf[txt_len] = '\0';
716
717 h = buf;
718
719 symbol_found = true;
720 }
721
722 return symbol_found;
723 }
724
725 // FIXME: It's not likely that this does the right thing now.
726
728 {
729 help_system& help_sys = __get_help_system__ ("make_name_list");
730
731 return help_sys.make_name_list ();
732 }
733
734DEFMETHOD (get_help_text, interp, args, ,
735 doc: /* -*- texinfo -*-
736@deftypefn {} {[@var{text}, @var{format}] =} get_help_text (@var{name})
737Return the raw help text of function @var{name}.
738
739The raw help text is returned in @var{text} and the format in @var{format}.
740The format is a string which is one of @qcode{"texinfo"}, @qcode{"html"}, or
741@w{@qcode{"plain text"}}.
742@seealso{get_help_text_from_file}
743@end deftypefn */)
744{
745 if (args.length () != 1)
746 print_usage ();
747
748 const std::string name = args(0).xstring_value ("get_help_text: NAME must be a string");
749
750 help_system& help_sys = interp.get_help_system ();
751
752 std::string text, format;
753
754 help_sys.get_help_text (name, text, format);
755
756 return ovl (text, format);
757}
758
759DEFMETHOD (get_help_text_from_file, interp, args, ,
760 doc: /* -*- texinfo -*-
761@deftypefn {} {[@var{text}, @var{format}] =} get_help_text_from_file (@var{fname})
762Return the raw help text from the file @var{fname}.
763
764The raw help text is returned in @var{text} and the format in @var{format}.
765The format is a string which is one of @qcode{"texinfo"}, @qcode{"html"}, or
766@w{@qcode{"plain text"}}.
767@seealso{get_help_text}
768@end deftypefn */)
769{
770 if (args.length () != 1)
771 print_usage ();
772
773 const std::string fname = args(0).xstring_value ("get_help_text_from_file: NAME must be a string");
774
775 help_system& help_sys = interp.get_help_system ();
776
777 std::string text, format;
778
779 help_sys.get_help_text_from_file (fname, text, format);
780
781 return ovl (text, format);
782}
783
784// Return a cell array of strings containing the names of all operators.
785
786DEFUN (__operators__, , ,
787 doc: /* -*- texinfo -*-
788@deftypefn {} {} __operators__ ()
789Undocumented internal function.
790@end deftypefn */)
791{
792 return ovl (Cell (operator_names));
793}
794
795// Return a cell array of strings containing the names of all keywords.
796// iskeyword() function is located in lex.ll and is based on what the parser
797// thinks is a keyword.
798
799DEFALIAS (__keywords__, iskeyword)
800
801// Return a cell array of strings with the names of all builtin functions.
802
803DEFMETHOD (__builtins__, interp, , ,
804 doc: /* -*- texinfo -*-
805@deftypefn {} {} __builtins__ ()
806Undocumented internal function.
807@end deftypefn */)
808{
809 symbol_table& symtab = interp.get_symbol_table ();
810
811 const string_vector bif = symtab.built_in_function_names ();
812
813 return ovl (Cell (bif));
814}
815
816DEFMETHOD (localfunctions, interp, args, ,
817 doc: /* -*- texinfo -*-
818@deftypefn {} {} localfunctions ()
819Return a list of all local functions, i.e., subfunctions, within the current
820file.
821
822The return value is a column cell array of function handles to all local
823functions accessible from the function from which @code{localfunctions} is
824called. Nested functions are @emph{not} included in the list.
825
826If the call is from the command line, an anonymous function, or a script,
827the return value is an empty cell array.
828
829@seealso{functions}
830@end deftypefn */)
831{
832 if (args.length () != 0)
833 print_usage ();
834
835 Cell retval;
836
837 // Find the main function we are in.
838 tree_evaluator& tw = interp.get_evaluator ();
839 octave_user_code *caller = tw.debug_user_code ();
840
841 if (! caller)
842 return ovl (retval);
843
844 symbol_scope scope = caller->scope ();
845
846 return ovl (Cell (scope.localfunctions ()));
847}
848
849/*
850%!test
851%! f = tempname (tempdir (), "oct_");
852%! [~, fcn_name] = fileparts (f);
853%! f = [f ".m"];
854%! save_path = path ();
855%! unwind_protect
856%! addpath (tempdir ());
857%! fid = fopen (f, "w+");
858%! fprintf (fid, "function z = %s\n z = localfunctions; end\n", fcn_name);
859%! fprintf (fid, "function z = b(x)\n z = x+1; end\n");
860%! fprintf (fid, "function z = c(x)\n z = 2*x; end\n");
861%! fclose (fid);
862%! d = eval (fcn_name);
863%! assert (size (d), [2, 1]);
864%! assert (d{1} (3), 4);
865%! assert (d{2} (3), 6);
866%! unwind_protect_cleanup
867%! unlink (f);
868%! path (save_path);
869%! end_unwind_protect
870*/
871
872DEFMETHOD (__which__, interp, args, ,
873 doc: /* -*- texinfo -*-
874@deftypefn {} {} __which__ (@var{name}, @dots{})
875Undocumented internal function.
876@end deftypefn */)
877{
878 help_system& help_sys = interp.get_help_system ();
879
880 string_vector argv = args.make_argv ();
881
882 int nargin = argv.numel ();
883
884 octave_map m (dim_vector (1, nargin));
885
886 Cell names (1, nargin);
887 Cell files (1, nargin);
888 Cell types (1, nargin);
889
890 for (int i = 0; i < nargin; i++)
891 {
892 std::string name = argv[i];
893
894 std::string type;
895
896 std::string file = help_sys.which (name, type);
897
898 names(i) = name;
899 files(i) = file;
900 types(i) = type;
901 }
902
903 m.assign ("name", names);
904 m.assign ("file", files);
905 m.assign ("type", types);
906
907 return ovl (m);
908}
909
910// Return a cell array of strings containing the names of all
911// functions available in DIRECTORY. If no directory is given, search
912// the current path.
913
914DEFMETHOD (__list_functions__, interp, args, ,
915 doc: /* -*- texinfo -*-
916@deftypefn {} {@var{retval} =} __list_functions__ ()
917@deftypefnx {} {@var{retval} =} __list_functions__ (@var{directory})
918Return a list of all functions (.m and .oct functions) in the load path.
919
920If the optional argument @var{directory} is given then list only the functions
921in that directory.
922@seealso{path}
923@end deftypefn */)
924{
925 octave_value retval;
926
927 load_path& lp = interp.get_load_path ();
928
929 if (args.length () == 0)
930 {
931 // Get list of all functions
932 string_vector ffl = lp.fcn_names ();
933 string_vector afl = interp.autoloaded_functions ();
934
935 retval = Cell (ffl.append (afl));
936 }
937 else
938 {
939 std::string dir = args(0).xstring_value ("__list_functions__: DIRECTORY argument must be a string");
940
941 string_vector fl = lp.files (dir, true);
942
943 // Return a sorted list with unique entries (in case of .m and .oct
944 // versions of the same function in a given directory, for example).
945 fl.sort (true);
946
947 retval = Cell (fl);
948 }
949
950 return retval;
951}
952
953DEFMETHOD (built_in_docstrings_file, interp, args, nargout,
954 doc: /* -*- texinfo -*-
955@deftypefn {} {@var{val} =} built_in_docstrings_file ()
956@deftypefnx {} {@var{old_val} =} built_in_docstrings_file (@var{new_val})
957@deftypefnx {} {} built_in_docstrings_file (@var{new_val}, "local")
958Query or set the internal variable that specifies the name of the
959file containing docstrings for built-in Octave functions.
960
961The default value is
962@file{@var{octave-home}/share/octave/@var{version}/etc/built-in-docstrings},
963in which @var{octave-home} is the root directory of the Octave installation,
964and @var{version} is the Octave version number. The default value may be
965overridden by the environment variable
966@w{@env{OCTAVE_BUILT_IN_DOCSTRINGS_FILE}}, or the command line argument
967@option{--built-in-docstrings-file FNAME}.
968
969Note: This variable is only used when Octave is initializing itself.
970Modifying it during a running session of Octave will have no effect.
971@end deftypefn */)
972{
973 help_system& help_sys = interp.get_help_system ();
974
975 return help_sys.built_in_docstrings_file (args, nargout);
976}
977
978DEFMETHOD (doc_cache_file, interp, args, nargout,
979 doc: /* -*- texinfo -*-
980@deftypefn {} {@var{val} =} doc_cache_file ()
981@deftypefnx {} {@var{old_val} =} doc_cache_file (@var{new_val})
982@deftypefnx {} {} doc_cache_file (@var{new_val}, "local")
983Query or set the internal variable that specifies the name of the
984Octave documentation cache file.
985
986A cache file significantly improves the performance of the @code{lookfor}
987command. The default value is
988@file{@var{octave-home}/share/octave/@var{version}/etc/doc-cache},
989in which @var{octave-home} is the root directory of the Octave installation,
990and @var{version} is the Octave version number.
991The default value may be overridden by the environment variable
992@w{@env{OCTAVE_DOC_CACHE_FILE}}, or the command line argument
993@option{--doc-cache-file FNAME}.
994
995When called from inside a function with the @qcode{"local"} option, the
996variable is changed locally for the function and any subroutines it calls.
997The original variable value is restored when exiting the function.
998@seealso{doc_cache_create, lookfor, info_program, doc, help, makeinfo_program}
999@seealso{lookfor}
1000@end deftypefn */)
1001{
1002 help_system& help_sys = interp.get_help_system ();
1003
1004 return help_sys.doc_cache_file (args, nargout);
1005}
1006
1007DEFMETHOD (info_file, interp, args, nargout,
1008 doc: /* -*- texinfo -*-
1009@deftypefn {} {@var{val} =} info_file ()
1010@deftypefnx {} {@var{old_val} =} info_file (@var{new_val})
1011@deftypefnx {} {} info_file (@var{new_val}, "local")
1012Query or set the internal variable that specifies the name of the
1013Octave info file.
1014
1015The default value is
1016@file{@var{octave-home}/share/info/octave.info}, in
1017which @var{octave-home} is the root directory of the Octave installation.
1018The default value may be overridden by the environment variable
1019@w{@env{OCTAVE_INFO_FILE}}, or the command line argument
1020@option{--info-file FNAME}.
1021
1022When called from inside a function with the @qcode{"local"} option, the
1023variable is changed locally for the function and any subroutines it calls.
1024The original variable value is restored when exiting the function.
1025@seealso{info_program, doc, help, makeinfo_program}
1026@end deftypefn */)
1027{
1028 help_system& help_sys = interp.get_help_system ();
1029
1030 return help_sys.info_file (args, nargout);
1031}
1032
1033DEFMETHOD (info_program, interp, args, nargout,
1034 doc: /* -*- texinfo -*-
1035@deftypefn {} {@var{val} =} info_program ()
1036@deftypefnx {} {@var{old_val} =} info_program (@var{new_val})
1037@deftypefnx {} {} info_program (@var{new_val}, "local")
1038Query or set the internal variable that specifies the name of the
1039info program to run.
1040
1041The default value is @file{info}. The default value may be
1042overridden by the environment variable @w{@env{OCTAVE_INFO_PROGRAM}}, or the
1043command line argument @option{--info-program NAME}.
1044
1045When called from inside a function with the @qcode{"local"} option, the
1046variable is changed locally for the function and any subroutines it calls.
1047The original variable value is restored when exiting the function.
1048@seealso{info_file, doc, help, makeinfo_program}
1049@end deftypefn */)
1050{
1051 help_system& help_sys = interp.get_help_system ();
1052
1053 return help_sys.info_program (args, nargout);
1054}
1055
1056DEFMETHOD (makeinfo_program, interp, args, nargout,
1057 doc: /* -*- texinfo -*-
1058@deftypefn {} {@var{val} =} makeinfo_program ()
1059@deftypefnx {} {@var{old_val} =} makeinfo_program (@var{new_val})
1060@deftypefnx {} {} makeinfo_program (@var{new_val}, "local")
1061Query or set the internal variable that specifies the name of the
1062program that Octave runs to format help text containing
1063Texinfo markup commands.
1064
1065The default value is @code{makeinfo}.
1066
1067When called from inside a function with the @qcode{"local"} option, the
1068variable is changed locally for the function and any subroutines it calls.
1069The original variable value is restored when exiting the function.
1070@seealso{texi_macros_file, info_file, info_program, doc, help}
1071@end deftypefn */)
1072{
1073 help_system& help_sys = interp.get_help_system ();
1074
1075 return help_sys.makeinfo_program (args, nargout);
1076}
1077
1078DEFMETHOD (suppress_verbose_help_message, interp, args, nargout,
1079 doc: /* -*- texinfo -*-
1080@deftypefn {} {@var{val} =} suppress_verbose_help_message ()
1081@deftypefnx {} {@var{old_val} =} suppress_verbose_help_message (@var{new_val})
1082@deftypefnx {} {} suppress_verbose_help_message (@var{new_val}, "local")
1083Query or set the internal variable that controls whether Octave
1084will add additional help information to the end of the output from
1085the @code{help} command and usage messages for built-in commands.
1086
1087When called from inside a function with the @qcode{"local"} option, the
1088variable is changed locally for the function and any subroutines it calls.
1089The original variable value is restored when exiting the function.
1090@end deftypefn */)
1091{
1092 help_system& help_sys = interp.get_help_system ();
1093
1094 return help_sys.suppress_verbose_help_message (args, nargout);
1095}
1096
1097DEFMETHOD (texi_macros_file, interp, args, nargout,
1098 doc: /* -*- texinfo -*-
1099@deftypefn {} {@var{val} =} texi_macros_file ()
1100@deftypefnx {} {@var{old_val} =} texi_macros_file (@var{new_val})
1101@deftypefnx {} {} texi_macros_file (@var{new_val}, "local")
1102Query or set the internal variable that specifies the name of the
1103file containing Texinfo macros that are prepended to documentation strings
1104before they are passed to makeinfo.
1105
1106The default value is
1107@file{@var{octave-home}/share/octave/@var{version}/etc/macros.texi},
1108in which @var{octave-home} is the root directory of the Octave installation,
1109and @var{version} is the Octave version number.
1110The default value may be overridden by the environment variable
1111@w{@env{OCTAVE_TEXI_MACROS_FILE}}, or the command line argument
1112@option{--texi-macros-file FNAME}.
1113
1114When called from inside a function with the @qcode{"local"} option, the
1115variable is changed locally for the function and any subroutines it calls.
1116The original variable value is restored when exiting the function.
1117@seealso{makeinfo_program}
1118@end deftypefn */)
1119{
1120 help_system& help_sys = interp.get_help_system ();
1121
1122 return help_sys.texi_macros_file (args, nargout);
1123}
1124
1125OCTAVE_NAMESPACE_END
charNDArray max(char d, const charNDArray &m)
Definition: chNDArray.cc:230
Definition: Cell.h:43
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:94
std::string m_makeinfo_program
Definition: help.h:161
bool m_suppress_verbose_help_message
Definition: help.h:165
static std::string init_texi_macros_file(void)
bool raw_help_from_symbol_table(const std::string &nm, std::string &h, std::string &w, bool &symbol_found) const
void get_help_text_from_file(const std::string &fname, std::string &text, std::string &format) const
bool raw_help_from_file(const std::string &nm, std::string &h, std::string &file, bool &symbol_found) const
std::string info_program(void) const
Definition: help.h:89
std::string m_doc_cache_file
Definition: help.h:150
string_vector make_name_list(void) const
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 raw_help_from_docstrings_file(const std::string &nm, std::string &h, bool &symbol_found) const
std::string m_info_file
Definition: help.h:154
static std::string init_info_program(void)
std::string m_built_in_docstrings_file
Definition: help.h:146
interpreter & m_interpreter
Definition: help.h:142
std::string which(const std::string &name) const
octave_value info_file(const octave_value_list &args, int nargout)
std::string doc_cache_file(void) const
Definition: help.h:71
static std::string init_doc_cache_file(void)
static std::string init_built_in_docstrings_file(void)
std::string m_texi_macros_file
Definition: help.h:170
std::string makeinfo_program(void) const
Definition: help.h:98
static std::string init_info_file(void)
octave_value info_program(const octave_value_list &args, int nargout)
bool suppress_verbose_help_message(void) const
Definition: help.h:108
std::string texi_macros_file(void) const
Definition: help.h:120
std::string built_in_docstrings_file(void) const
Definition: help.h:62
std::string info_file(void) const
Definition: help.h:80
string_vector local_functions(void) const
octave_value suppress_verbose_help_message(const octave_value_list &args, int nargout)
octave_value doc_cache_file(const octave_value_list &args, int nargout)
std::string m_info_program
Definition: help.h:158
octave_value makeinfo_program(const octave_value_list &args, int nargout)
octave_value texi_macros_file(const octave_value_list &args, int nargout)
load_path & get_load_path(void)
Definition: interpreter.h:281
tree_evaluator & get_evaluator(void)
symbol_table & get_symbol_table(void)
Definition: interpreter.h:296
std::list< std::string > variable_names(void)
std::list< std::string > autoloaded_functions(void) const
string_vector files(const std::string &dir, bool omit_exts=false) const
Definition: load-path.cc:922
std::string find_file(const std::string &file) const
Definition: load-path.cc:602
string_vector fcn_names(void) const
Definition: load-path.cc:950
std::string find_fcn_file(const std::string &fcn, const std::string &pack_name="")
Definition: load-path.h:131
virtual bool is_user_function(void) const
Definition: ov-base.h:507
virtual bool is_classdef_meta(void) const
Definition: ov-base.h:427
OCTINTERP_API bool is_classdef_method(const std::string &cname="") const
Definition: ov-classdef.cc:404
OCTINTERP_API bool is_classdef_constructor(const std::string &cname="") const
Definition: ov-classdef.cc:423
OCTINTERP_API std::string file_name(void) const
Definition: ov-classdef.cc:461
virtual std::string fcn_file_name(void) const
Definition: ov-fcn.h:78
virtual std::string doc_string(const std::string &="") const
Definition: ov-fcn.h:220
virtual std::list< std::string > subfunction_names(void) const
Definition: ov-fcn.h:200
virtual std::string src_file_name(void) const
Definition: ov-fcn.h:80
virtual bool is_subfunction(void) const
Definition: ov-fcn.h:109
virtual octave::symbol_scope parent_fcn_scope(void) const
Definition: ov-fcn.h:87
octave::symbol_scope scope(void)
Definition: ov-usr-fcn.h:93
OCTINTERP_API octave_function * function_value(bool silent=false) const
bool is_defined(void) const
Definition: ov.h:637
bool is_user_script(void) const
Definition: ov.h:825
string_vector & append(const std::string &s)
Definition: str-vec.cc:110
string_vector & sort(bool make_uniq=false)
Definition: str-vec.cc:77
void resize(octave_idx_type n, const std::string &rfv="")
Definition: str-vec.h:95
octave_idx_type numel(void) const
Definition: str-vec.h:100
std::list< std::string > cmdline_function_names(void)
Definition: symtab.cc:615
octave_value find_function(const std::string &name, const symbol_scope &search_scope=symbol_scope())
Definition: symtab.cc:249
std::list< std::string > built_in_function_names(void)
Definition: symtab.cc:597
octave_user_code * current_user_code(void) const
Definition: pt-eval.cc:2503
octave_user_code * debug_user_code(void) const
Definition: pt-eval.cc:2513
OCTINTERP_API void print_usage(void)
Definition: defun-int.h:72
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
Definition: defun.h:111
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
Definition: defun.h:56
#define DEFALIAS(alias, name)
Macro to define an alias for another existing function name.
Definition: defun.h:160
void error(const char *fmt,...)
Definition: error.cc:980
QString name
string_vector make_name_list(void)
OCTAVE_NAMESPACE_BEGIN OCTAVE_EXPORT octave_value_list Fiskeyword(const octave_value_list &args, int)
Definition: lex.cc:5019
OCTAVE_NAMESPACE_BEGIN bool iskeyword(const std::string &s)
Definition: lex.cc:1359
F77_RET_T const F77_DBLE const F77_DBLE * f
std::complex< double > w(std::complex< double > z, double relerr=0)
std::string oct_etc_dir(void)
Definition: defaults.cc:339
std::string prepend_octave_home(const std::string &s)
Definition: defaults.cc:125
std::string dir_sep_str(void)
Definition: file-ops.cc:238
std::ifstream ifstream(const std::string &filename, const std::ios::openmode mode)
Definition: lo-sysdep.cc:400
help_system & __get_help_system__(const std::string &who)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Definition: oct-locbuf.h:44
std::string get_help_from_file(const std::string &nm, bool &symbol_found, std::string &full_file)
Definition: oct-parse.cc:9994
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
Definition: ovl.h:211
static string_vector make_absolute(const string_vector &sv)
Definition: utils.cc:535
std::size_t format(std::ostream &os, const char *fmt,...)
Definition: utils.cc:1471
octave_value set_internal_variable(bool &var, const octave_value_list &args, int nargout, const char *nm)
Definition: variables.cc:587
F77_RET_T len
Definition: xerbla.cc:61