Mercurial > octave
diff libinterp/corefcn/help.cc @ 28514:fab862fedf85 stable
allow help to find docstrings for classdef classes and methods (bug #43047)
* help.cc (help_system::raw_help_from_symbol_table): Also find
docstrings from classdef meta objects (both classes and methods).
* cdef-class.h, cdef-class.cc (cdef_class::cdef_class_rep,
cdef_class): Store docstring for class and provide access.
* ov-classdef.h, ov-classdef.cc (octave_classdef_meta::doc_string):
New function to provide access to doc strings for classdef objects
and methods.
* ov-fcn.h (octave_function::doc_string): Now virtual. New argument
for method name.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 29 May 2020 10:57:04 -0400 |
parents | 71c34141cc2d |
children | 70d155283f33 68e6e6f083f3 |
line wrap: on
line diff
--- a/libinterp/corefcn/help.cc Fri May 29 10:56:22 2020 -0400 +++ b/libinterp/corefcn/help.cc Fri May 29 10:57:04 2020 -0400 @@ -523,33 +523,47 @@ std::string& h, std::string& w, bool& symbol_found) const { - bool retval = false; + std::string meth_nm; symbol_table& symtab = m_interpreter.get_symbol_table (); octave_value val = symtab.find_function (nm); + if (! val.is_defined ()) + { + size_t pos = nm.rfind ('.'); + + if (pos != std::string::npos) + { + meth_nm = nm.substr (pos+1); + + val = symtab.find_function (nm.substr (0, pos)); + } + } + if (val.is_defined ()) { octave_function *fcn = val.function_value (); if (fcn) { + // FCN may actually be a classdef_meta object. + symbol_found = true; - h = fcn->doc_string (); - - retval = true; + h = fcn->doc_string (meth_nm); w = fcn->fcn_file_name (); if (w.empty ()) w = fcn->is_user_function () ? "command-line function" - : "built-in function"; + : "built-in function"; + + return true; } } - return retval; + return false; } bool help_system::raw_help_from_file (const std::string& nm,