changeset 9530:f3df413338c5

print_usage: support calling from methods
author Jaroslav Hajek <highegg@gmail.com>
date Mon, 17 Aug 2009 13:59:26 +0200
parents 8e5009334661
children b859079d1644
files scripts/ChangeLog scripts/help/print_usage.m
diffstat 2 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Mon Aug 17 13:09:12 2009 +0200
+++ b/scripts/ChangeLog	Mon Aug 17 13:59:26 2009 +0200
@@ -1,3 +1,7 @@
+2009-08-17  Jaroslav Hajek  <highegg@gmail.com>
+
+	* help/print_usage: Allow calling from methods.
+
 2009-08-11  Jaroslav Hajek  <highegg@gmail.com>
 
 	* general/diff.m: Remove.
--- a/scripts/help/print_usage.m	Mon Aug 17 13:09:12 2009 +0200
+++ b/scripts/help/print_usage.m	Mon Aug 17 13:59:26 2009 +0200
@@ -33,12 +33,18 @@
     else
       error ("print_usage: invalid function\n");
     endif
+    path = evalin ("caller", "mfilename (""fullpath"")");
+    if (strcmp (path(end-length(name)+1:end), name))
+      path = [path, ".m"];
+    else
+      path = name;
+    endif
   elseif (!ischar (name))
     error ("print_usage: input argument must be a string");
   endif
   
   ## Do the actual work
-  [text, format] = get_help_text (name);
+  [text, format] = get_help_text (path);
   max_len = 80;
   switch (lower (format))
     case "plain text"