changeset 33140:8504d3f2b17e

maint: merge stable to default
author Rik <rik@octave.org>
date Mon, 04 Mar 2024 10:18:00 -0800
parents 0a8166b45c29 (current diff) 4e0f8b80bd2f (diff)
children 440ef081efd8
files
diffstat 2 files changed, 59 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/help.cc	Sun Mar 03 11:55:34 2024 -0800
+++ b/libinterp/corefcn/help.cc	Mon Mar 04 10:18:00 2024 -0800
@@ -684,6 +684,52 @@
   return symbol_found;
 }
 
+bool
+help_system::raw_help_for_class (const cdef_class& cls,
+                                 const std::string& name,
+                                 std::string& help, std::string& what,
+                                 bool& symbol_found) const
+{
+  if (cls.ok ())
+    {
+      // Is the class documented?
+      help = cls.doc_string ();
+
+      if (! help.empty ())
+        {
+          what = "class";
+
+          symbol_found = true;
+          return true;
+        }
+
+      // Look for constructor.
+      std::size_t pos = name.rfind ('.');
+
+      if (pos != std::string::npos)
+        {
+          std::string nm = name.substr (pos+1);
+
+          octave_value ov_meth = cls.get_method (nm);
+
+          if (get_help_from_fcn (nm, ov_meth, help, what, symbol_found))
+            {
+              what = "constructor";
+              return true;
+            }
+        }
+
+      // 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";
+      symbol_found = true;
+      return true;
+    }
+
+  return false;
+}
+
 // FIXME: There is a lot of duplication between the following function
 // and help_system::which.  Some refactoring would probably be useful.
 
@@ -734,45 +780,8 @@
 
   cdef_class cls = cdm.find_class (name, false, true);
 
-  if (cls.ok ())
-    {
-      // Is the class documented?
-
-      help = cls.doc_string ();
-
-      if (! help.empty ())
-        {
-          what = "class";
-
-          symbol_found = true;
-          return true;
-        }
-
-      // Look for constructor.
-
-      pos = name.rfind ('.');
-
-      if (pos != std::string::npos)
-        {
-          std::string nm = name.substr (pos+1);
-
-          octave_value ov_meth = cls.get_method (nm);
-
-          if (get_help_from_fcn (nm, ov_meth, help, what, symbol_found))
-            {
-              what = "constructor";
-              return true;
-            }
-        }
-
-      // We found a class but no doc string for it or its constructor.
-      // Create a generic doc string.
-
-      help = name + " is an undocumented class";
-      what = "class";
-      symbol_found = true;
-      return true;
-    }
+  if (raw_help_for_class (cls, name, help, what, symbol_found))
+    return true;
 
   cdef_package pkg = cdm.find_package (name, false, true);
 
@@ -795,7 +804,9 @@
 
   cls = cdm.find_class (prefix, false, true);
 
-  if (cls.ok ())
+  bool found_class = cls.ok ();
+
+  if (found_class)
     {
       // FIXME: Should we only find public methods here?
 
@@ -833,6 +844,9 @@
         return true;
     }
 
+  if (nm == "m" && raw_help_for_class (cls, prefix, help, what, symbol_found))
+    return true;
+
   return false;
 }
 
--- a/libinterp/corefcn/help.h	Sun Mar 03 11:55:34 2024 -0800
+++ b/libinterp/corefcn/help.h	Mon Mar 04 10:18:00 2024 -0800
@@ -38,6 +38,7 @@
 
 OCTAVE_BEGIN_NAMESPACE(octave)
 
+class cdef_class;
 class interpreter;
 
 class help_system
@@ -191,6 +192,10 @@
 
   string_vector local_functions () const;
 
+  bool raw_help_for_class (const cdef_class& cls, const std::string& nm,
+                           std::string& h, std::string& w,
+                           bool& symbol_found) const;
+
   bool raw_help_from_symbol_table (const std::string& nm,
                                    std::string& h, std::string& w,
                                    bool& symbol_found) const;