26 #if defined (HAVE_CONFIG_H)
49 #include "builtin-defun-decls.h"
74 #include "default-defs.h"
78 const static char *
const operators[] =
131 looks_like_html (
const std::string& msg)
133 const size_t p1 = msg.find (
'\n');
134 std::string t = msg.substr (0, p1);
136 const size_t p2 = t.find (
"<html");
138 return (p2 != std::string::npos);
142 looks_like_texinfo (
const std::string& msg,
size_t& p1)
144 p1 = msg.find (
'\n');
146 std::string t = msg.substr (0, p1);
148 if (p1 == std::string::npos)
151 size_t p2 = t.find (
"-*- texinfo -*-");
153 return (p2 != std::string::npos);
161 "built_in_docstrings_file",
false);
168 "doc_cache_file",
false);
182 "info_program",
false);
189 "makeinfo_program",
false);
197 nargout,
"suppress_verbose_help_message");
204 "texi_macros_file",
false);
221 bool external_doc = h.compare (0, 12,
"external-doc") == 0;
223 if (! found || external_doc)
225 std::string tmp_nm = nm;
227 if (external_doc && h.length () > 12 && h[12] ==
':')
228 tmp_nm = h.substr (13);
237 std::string&
type)
const
246 if (
name.find_first_of (
'.') == std::string::npos)
263 type =
"command-line function";
267 type =
"built-in function";
293 file = lp.find_file (
name);
313 const static int key_len = keywords.
numel ();
318 const int bif_len = bif.
numel ();
321 const int cfl_len = cfl.
numel ();
324 const int lcl_len = lcl.
numel ();
329 const int ffl_len = ffl.
numel ();
332 const int afl_len = afl.
numel ();
335 const int lfl_len = lfl.
numel ();
338 = key_len + bif_len + cfl_len + lcl_len + ffl_len + afl_len + lfl_len;
347 for (i = 0; i < key_len; i++)
348 list[j++] = keywords[i];
350 for (i = 0; i < bif_len; i++)
353 for (i = 0; i < cfl_len; i++)
356 for (i = 0; i < lcl_len; i++)
359 for (i = 0; i < ffl_len; i++)
362 for (i = 0; i < afl_len; i++)
365 for (i = 0; i < lfl_len; i++)
372 std::string&
format)
const
374 bool symbol_found =
false;
383 format =
"Not documented";
385 else if (looks_like_texinfo (
text, idx))
390 else if (looks_like_html (
text))
403 std::string&
format)
const
405 bool symbol_found =
false;
417 format =
"Not documented";
419 else if (looks_like_texinfo (
text, idx))
424 else if (looks_like_html (
text))
453 return (env_file.empty () ? def_file : env_file);
462 return (oct_info_file.empty () ? std_info_file : oct_info_file);
469 if (info_prog.empty ())
482 return (env_file.empty () ? def_file : env_file);
505 curr_fcn = pscope.user_code ();
511 size_t sz = names.size ();
516 for (
const auto& nm : names)
523 std::string& h, std::string&
w,
524 bool& symbol_found)
const
534 size_t pos = nm.rfind (
'.');
536 if (pos != std::string::npos)
538 meth_nm = nm.substr (pos+1);
540 val = symtab.find_function (nm.substr (0, pos));
560 :
"built-in function";
570 std::string& h, std::string& file,
571 bool& symbol_found)
const
586 bool& symbol_found)
const
588 typedef std::pair<std::streampos, std::streamoff> txt_limits_type;
589 typedef std::map<std::string, txt_limits_type> help_txt_map_type;
591 static help_txt_map_type help_txt_map;
592 static bool initialized =
false;
595 symbol_found =
false;
604 std::ios::in | std::ios::binary);
607 error (
"failed to open docstrings file: %s",
614 error (
"invalid built-in-docstrings file!");
617 size_t bufsize = 1000;
620 while (! file.eof ())
625 while (file && (c = file.get ()) != std::istream::traits_type::eof ())
627 if (c ==
'\n' || c ==
'\r')
641 && (c = file.get ()) != std::istream::traits_type::eof ()
642 && c !=
'\n' && c !=
'\r')
647 && (c = file.get ()) != std::istream::traits_type::eof ()
648 && (c ==
'\n' || c ==
'\r'))
654 std::streampos beg = file.tellg ();
663 len = file.tellg () - beg - 1;
666 file.seekg (0, file.end);
667 len = file.tellg () - beg - 1;
668 file.setstate (file.eofbit);
671 help_txt_map[
name] = txt_limits_type (beg,
len);
677 help_txt_map_type::const_iterator it = help_txt_map.find (nm);
679 if (it != help_txt_map.end ())
681 txt_limits_type txt_limits = it->second;
683 std::streampos beg = txt_limits.first;
684 std::streamoff
len = txt_limits.second;
687 std::ios::in | std::ios::binary);
690 error (
"failed to open docstrings file: %s",
695 size_t txt_len =
len;
698 file.read (buf, txt_len);
716 return help_sys.make_name_list ();
720 DEFMETHOD (get_help_text, interp, args, ,
731 if (args.length () != 1)
734 const std::string
name = args(0).xstring_value (
"get_help_text: NAME must be a string");
745 DEFMETHOD (get_help_text_from_file, interp, args, ,
756 if (args.length () != 1)
759 const std::string fname = args(0).xstring_value (
"get_help_text_from_file: NAME must be a string");
772 DEFUN (__operators__, , ,
778 return ovl (
Cell (octave::operator_names));
802 DEFMETHOD (localfunctions, interp, args, ,
818 if (args.length () != 0)
868 int nargin = argv.
numel ();
872 Cell names (1, nargin);
873 Cell files (1, nargin);
874 Cell types (1, nargin);
876 for (
int i = 0; i < nargin; i++)
878 std::string
name = argv[i];
889 m.assign (
"name", names);
890 m.assign (
"file", files);
891 m.assign (
"type", types);
900 DEFMETHOD (__list_functions__, interp, args, ,
915 if (args.length () == 0)
925 std::string dir = args(0).xstring_value (
"__list_functions__: DIRECTORY argument must be a string");
939 DEFMETHOD (built_in_docstrings_file, interp, args, nargout,
964 DEFMETHOD (doc_cache_file, interp, args, nargout,
993 DEFMETHOD (info_file, interp, args, nargout,
1016 return help_sys.
info_file (args, nargout);
1019 DEFMETHOD (info_program, interp, args, nargout,
1042 DEFMETHOD (makeinfo_program, interp, args, nargout,
1064 DEFMETHOD (suppress_verbose_help_message, interp, args, nargout,
1083 DEFMETHOD (texi_macros_file, interp, args, nargout,
charNDArray max(char d, const charNDArray &m)
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
Vector representing the dimensions (size) of an Array.
std::string raw_help(const std::string &, bool &) const
octave_value info_program(const octave_value_list &args, int nargout)
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
std::string makeinfo_program(void) const
octave_value texi_macros_file(const octave_value_list &args, int nargout)
bool suppress_verbose_help_message(void) const
std::string doc_cache_file(void) const
bool raw_help_from_symbol_table(const std::string &nm, std::string &h, std::string &w, bool &symbol_found) const
interpreter & m_interpreter
bool m_suppress_verbose_help_message
std::string built_in_docstrings_file(void) const
string_vector make_name_list(void) const
std::string info_program(void) const
std::string m_built_in_docstrings_file
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
octave_value makeinfo_program(const octave_value_list &args, int nargout)
std::string info_file(void) const
octave_value built_in_docstrings_file(const octave_value_list &args, int nargout)
static std::string init_info_file(void)
static std::string init_texi_macros_file(void)
std::string texi_macros_file(void) const
std::string m_info_program
std::string m_makeinfo_program
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
octave_value doc_cache_file(const octave_value_list &args, int nargout)
static std::string init_built_in_docstrings_file(void)
std::list< std::string > variable_names(void)
std::list< std::string > autoloaded_functions(void) const
load_path & get_load_path(void)
symbol_table & get_symbol_table(void)
tree_evaluator & get_evaluator(void)
std::string find_fcn_file(const std::string &fcn, const std::string &pack_name="")
string_vector files(const std::string &dir, bool omit_exts=false) const
string_vector fcn_names(void) const
std::string find_file(const std::string &file) const
std::list< octave_value > localfunctions(void) const
std::list< std::string > built_in_function_names(void)
static std::string getenv(const std::string &name)
static std::string make_absolute(const std::string &s, const std::string &dot_path=get_current_directory())
octave_user_code * debug_user_code(void) const
virtual bool is_user_function(void) const
virtual std::string fcn_file_name(void) const
virtual std::string doc_string(const std::string &="") const
virtual std::list< std::string > subfunction_names(void) const
virtual std::string src_file_name(void) const
virtual bool is_subfunction(void) const
virtual octave::symbol_scope parent_fcn_scope(void) const
octave::symbol_scope scope(void)
bool is_defined(void) const
bool is_user_script(void) const
octave_function * function_value(bool silent=false) const
string_vector & append(const std::string &s)
string_vector & sort(bool make_uniq=false)
octave_idx_type numel(void) const
#define OCTAVE_TEXI_MACROS_FILE
#define OCTAVE_DOC_CACHE_FILE
OCTINTERP_API void print_usage(void)
#define DEFMETHOD(name, interp_name, args_name, nargout_name, doc)
Macro to define a builtin method.
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
#define DEFALIAS(alias, name)
Macro to define an alias for another existing function name.
void error(const char *fmt,...)
OCTAVE_EXPORT octave_value_list Fiskeyword(const octave_value_list &args, int)
std::complex< double > w(std::complex< double > z, double relerr=0)
std::string prepend_octave_home(const std::string &s)
std::string oct_etc_dir(void)
std::string dir_sep_str(void)
std::ifstream ifstream(const std::string &filename, const std::ios::openmode mode)
help_system & __get_help_system__(const std::string &who)
string_vector make_name_list(void)
static double f(double k, double l_nu, double c_pm)
bool iskeyword(const std::string &s)
size_t format(std::ostream &os, const char *fmt,...)
std::string get_help_from_file(const std::string &nm, bool &symbol_found, std::string &full_file)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
octave_value::octave_value(const Array< char > &chm, char type) return retval
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.
octave_value set_internal_variable(bool &var, const octave_value_list &args, int nargout, const char *nm)