Mercurial > octave
diff libinterp/corefcn/help.cc @ 33230:515c1cc1b45e
display function signature as help text for undocumented functions (bug #65258)
* ov-usr-fcn.h, ov-usr-fcn.cc (octave_user_function::signature):
New function.
* help.cc (get_help_from_fcn): If function is undocumented, set help
text to function signature.
(help_system::raw_help_for_class): If there is no "." in name, look
for class constructor doc string. If no constructor is defined,
set help to signature of default constructor.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 20 Mar 2024 23:14:22 -0400 |
parents | 4e0f8b80bd2f |
children | 92ca2f6c6b85 |
line wrap: on
line diff
--- a/libinterp/corefcn/help.cc Wed Mar 20 08:12:28 2024 +0100 +++ b/libinterp/corefcn/help.cc Wed Mar 20 23:14:22 2024 -0400 @@ -675,6 +675,20 @@ help = fcn->doc_string (fcn_nm); what = fcn->fcn_file_name (); + if (help.empty () && ov_fcn.is_user_function ()) + { + octave_user_function *ufcn = ov_fcn.user_function_value (); + + if (ufcn->is_classdef_constructor ()) + help = "undocumented constructor: "; + else if (ufcn->is_classdef_method ()) + help = "undocumented method: "; + else + help = "undocumented function: "; + + help += ufcn->signature (); + } + if (what.empty ()) what = fcn->is_user_function () ? "command-line function" : "built-in function"; @@ -719,10 +733,23 @@ } } - // We found a class, but no docstring for it or its constructor. - // Create a generic doc string. - help = name + " is an undocumented class"; - what = "class"; + // No dot in name and class is undocumented. Look for documented + // constructor. + + octave_value ov_meth = cls.get_method (name); + + if (get_help_from_fcn (name, ov_meth, help, what, symbol_found)) + { + what = "constructor"; + symbol_found = true; + return true; + } + + // We found a class, but no docstring for it and there is no + // constructor explicitly defined. + + help = "default constructor: obj = " + name + "()"; + what = "constructor"; symbol_found = true; return true; }