23 #if defined (HAVE_CONFIG_H) 45 #include "builtin-defun-decls.h" 73 #include "default-defs.h" 75 const static char *
const operators[] =
130 const size_t p1 = msg.find (
'\n');
133 const size_t p2 =
t.find (
"<html");
135 return (p2 != std::string::npos);
139 looks_like_texinfo (
const std::string& msg,
size_t& p1)
141 p1 = msg.find (
'\n');
145 if (p1 == std::string::npos)
148 size_t p2 =
t.find (
"-*- texinfo -*-");
150 return (p2 != std::string::npos);
160 "built_in_docstrings_file",
false);
167 "doc_cache_file",
false);
181 "info_program",
false);
188 "makeinfo_program",
false);
196 nargout,
"suppress_verbose_help_message");
203 "texi_macros_file",
false);
220 bool external_doc =
h.compare (0, 12,
"external-doc") == 0;
222 if (!
found || external_doc)
226 if (external_doc &&
h.length () > 12 &&
h[12] ==
':')
227 tmp_nm =
h.substr (13);
246 if (
name.find_first_of (
'.') == std::string::npos)
248 if (
val.is_defined ())
259 type =
"command-line function";
263 type =
"built-in function";
267 type =
val.is_user_script () ?
"script" :
"function";
287 file = lp.find_file (
name.substr (0,
name.size () - 1));
307 = Fiskeyword ()(0).string_vector_value ();
309 const static int key_len = keywords.
numel ();
314 const int bif_len = bif.
numel ();
317 const int cfl_len = cfl.
numel ();
320 const int lcl_len = lcl.
numel ();
325 const int ffl_len = ffl.
numel ();
328 const int afl_len = afl.
numel ();
331 const int lfl_len = lfl.
numel ();
334 = key_len + bif_len + cfl_len + lcl_len + ffl_len + afl_len + lfl_len;
343 for (
i = 0;
i < key_len;
i++)
344 list[j++] = keywords[
i];
346 for (
i = 0;
i < bif_len;
i++)
349 for (
i = 0;
i < cfl_len;
i++)
352 for (
i = 0;
i < lcl_len;
i++)
355 for (
i = 0;
i < ffl_len;
i++)
358 for (
i = 0;
i < afl_len;
i++)
361 for (
i = 0;
i < lfl_len;
i++)
370 bool symbol_found =
false;
379 format =
"Not documented";
381 else if (looks_like_texinfo (
text, idx))
386 else if (looks_like_html (
text))
401 bool symbol_found =
false;
413 format =
"Not documented";
415 else if (looks_like_texinfo (
text, idx))
420 else if (looks_like_html (
text))
449 return (env_file.empty () ? def_file : env_file);
458 return (oct_info_file.empty () ? std_info_file : oct_info_file);
465 if (info_prog.empty ())
478 return (env_file.empty () ? def_file : env_file);
501 curr_fcn = pscope.function ();
507 size_t sz = names.size ();
512 for (
const auto&
nm : names)
520 bool& symbol_found)
const 528 if (
val.is_defined ())
544 :
"built-in function";
553 bool& symbol_found)
const 568 bool& symbol_found)
const 570 typedef std::pair<std::streampos, std::streamoff> txt_limits_type;
571 typedef std::map<std::string, txt_limits_type> help_txt_map_type;
573 static help_txt_map_type help_txt_map;
577 symbol_found =
false;
586 std::ios::in | std::ios::binary);
589 error (
"failed to open docstrings file: %s",
596 error (
"invalid built-in-docstrings file!");
599 size_t bufsize = 1000;
602 while (!
file.eof ())
607 while (
file && (
c =
file.get ()) != std::istream::traits_type::eof ())
609 if (
c ==
'\n' ||
c ==
'\r')
623 && (
c =
file.get ()) != std::istream::traits_type::eof ()
624 &&
c !=
'\n' &&
c !=
'\r')
629 && (
c =
file.get ()) != std::istream::traits_type::eof ()
630 &&
c ==
'\n' &&
c ==
'\r')
636 std::streampos beg =
file.tellg ();
645 len =
file.tellg () - beg - 1;
649 len =
file.tellg () - beg - 1;
653 help_txt_map[
name] = txt_limits_type (beg, len);
659 help_txt_map_type::const_iterator it = help_txt_map.find (
nm);
661 if (it != help_txt_map.end ())
663 txt_limits_type txt_limits = it->second;
665 std::streampos beg = txt_limits.first;
666 std::streamoff len = txt_limits.second;
669 std::ios::in | std::ios::binary);
672 error (
"failed to open docstrings file: %s",
677 size_t txt_len = len;
680 file.read (buf, txt_len);
703 DEFMETHOD (get_help_text, interp, args, ,
714 if (args.length () != 1)
717 const std::string name = args(0).xstring_value (
"get_help_text: NAME must be a string");
728 DEFMETHOD (get_help_text_from_file, interp, args, ,
739 if (args.length () != 1)
742 const std::string fname = args(0).xstring_value (
"get_help_text_from_file: NAME must be a string");
755 DEFUN (__operators__, , ,
761 return ovl (
Cell (operator_names));
785 DEFMETHOD (localfunctions, interp, args, ,
801 if (args.length () != 0)
817 const std::map<std::string, octave_value>
h = parent_fcn->
subfunctions ();
819 size_t sz = names.size ();
824 for (
const auto&
nm : names)
826 std::map<std::string, octave_value>::const_iterator nm_fcn =
h.find (
nm);
827 if (nm_fcn !=
h.end ())
885 m.assign (
"name", names);
886 m.assign (
"file",
files);
887 m.assign (
"type", types);
896 DEFMETHOD (__list_functions__, interp, args, ,
911 if (args.length () == 0)
921 std::string dir = args(0).xstring_value (
"__list_functions__: DIRECTORY argument must be a string");
virtual std::list< std::string > subfunction_names(void) const
std::list< std::string > built_in_function_names(void)
static std::string init_texi_macros_file(void)
virtual std::map< std::string, octave_value > subfunctions(void) const
std::string doc_cache_file(void) const
bool m_suppress_verbose_help_message
virtual bool is_user_function(void) const
For example cd octave end example noindent changes the current working directory to file
is already an absolute the name is checked against the file system instead of Octave s loadpath In this if otherwise an empty string is returned If the first argument is a cell array of search each directory of the loadpath for element of the cell array and return the first that matches If the second optional argument return a cell array containing the list of all files that have the same name in the path If no files are found
#define OCTAVE_TEXI_MACROS_FILE
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
bool suppress_verbose_help_message(void) const
The value of lines which begin with a space character are not saved in the history list A value of all commands are saved on the history list
std::string oct_etc_dir(void)
static std::string init_doc_cache_file(void)
octave_user_code * debug_user_code(void) const
OCTINTERP_API void print_usage(void)
identity matrix If supplied two scalar respectively For allows like xample val
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE * f
OCTINTERP_API std::string get_help_from_file(const std::string &nm, bool &symbol_found, std::string &file)
bool raw_help_from_docstrings_file(const std::string &nm, std::string &h, bool &symbol_found) const
std::string built_in_docstrings_file(void) const
virtual std::string src_file_name(void) const
void get_help_text_from_file(const std::string &fname, std::string &text, std::string &format) const
string_vector fcn_names(void) const
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void error(const char *fmt,...)
bool raw_help_from_symbol_table(const std::string &nm, std::string &h, std::string &w, bool &symbol_found) const
octave_user_code * caller_user_code(size_t nskip=0) const
string_vector make_name_list(void) const
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
virtual std::string fcn_file_name(void) const
std::string m_makeinfo_program
std::string dir_sep_str(void)
static std::string getenv(const std::string &name)
octave_value makeinfo_program(const octave_value_list &args, int nargout)
octave_value resize(const dim_vector &dv, bool fill=false) const
octave_value info_program(const octave_value_list &args, int nargout)
bool raw_help_from_file(const std::string &nm, std::string &h, std::string &file, bool &symbol_found) const
std::string m_doc_cache_file
#define DEFALIAS(alias, name)
Macro to define an alias for another existing function name.
std::string prepend_octave_home(const std::string &s)
static std::string make_absolute(const std::string &s, const std::string &dot_path=get_current_directory())
help_system & __get_help_system__(const std::string &who)
nd deftypefn *std::string name
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
std::string doc_string(void) const
string_vector make_name_list(void)
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
interpreter & m_interpreter
load_path & get_load_path(void)
void get_help_text(const std::string &name, std::string &text, std::string &format) const
virtual bool is_subfunction(void) const
std::complex< double > w(std::complex< double > z, double relerr=0)
octave_value built_in_docstrings_file(const octave_value_list &args, int nargout)
string_vector & append(const std::string &s)
static std::string init_info_file(void)
string_vector & sort(bool make_uniq=false)
std::string m_texi_macros_file
string_vector files(const std::string &dir, bool omit_exts=false) const
std::string m_built_in_docstrings_file
end deftypefn *return set_internal_variable(Vsvd_driver, args, nargout, "svd_driver", driver_names)
OCTINTERP_API string_vector autoloaded_functions(void)
symbol_table & get_symbol_table(void)
#define OCTAVE_DOC_CACHE_FILE
std::string makeinfo_program(void) const
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
charNDArray max(char d, const charNDArray &m)
std::string raw_help(const std::string &, bool &) const
OCTAVE_EXPORT octave_value_list the first data row corresponds to an index of zero The a spreadsheet style form such as the file is read until end of file is reached The such as text
string_vector local_functions(void) const
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).isinteger())
std::string which(const std::string &name) const
otherwise an error message is printed The permission mask is a UNIX concept used when creating new objects on a file system such as files
octave_value info_file(const octave_value_list &args, int nargout)
octave_value doc_cache_file(const octave_value_list &args, int nargout)
call_stack & get_call_stack(void)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
std::string info_file(void) const
octave_value suppress_verbose_help_message(const octave_value_list &args, int nargout)
static std::string init_built_in_docstrings_file(void)
std::string m_info_program
octave_idx_type numel(void) const
Number of elements in the array.
std::string info_program(void) const
virtual octave::symbol_scope parent_fcn_scope(void) const
std::string texi_macros_file(void) const
Vector representing the dimensions (size) of an Array.
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
static std::string init_info_program(void)
octave_value texi_macros_file(const octave_value_list &args, int nargout)