# HG changeset patch # User Ben Abbott # Date 1273700968 14400 # Node ID 07933067e4ab4717afa5da49d8e8f038a65a7f03 # Parent 3eafa521550b7137ac59fbb48cec329fa90838c7 help.m: Allow docstring to be returned as output, and correct docstring. diff -r 3eafa521550b -r 07933067e4ab scripts/ChangeLog --- a/scripts/ChangeLog Wed May 12 02:25:05 2010 +0200 +++ b/scripts/ChangeLog Wed May 12 17:49:28 2010 -0400 @@ -1,3 +1,8 @@ +2010-05-12 Jordi GutiƩrrez Hermoso + + * help/help.m: Allow docstring to be returned as output, and + correct docstring. + 2010-05-08 Rik * testfun/test.m: Don't abort testing when skipping a testif block diff -r 3eafa521550b -r 07933067e4ab scripts/help/help.m --- a/scripts/help/help.m Wed May 12 02:25:05 2010 +0200 +++ b/scripts/help/help.m Wed May 12 17:49:28 2010 -0400 @@ -15,21 +15,24 @@ ## . ## -*- texinfo -*- -## @deffn {Command} help @var{name} +## @deftypefn {Function File} {} help @var{name} ## Display the help text for @var{name}. -## If invoked without any arguments, @code{help} prints a list -## of all the available operators and functions. +## If invoked without any arguments, @code{help} displays instructions +## on how to access help from the command line. ## ## For example, the command @kbd{help help} prints a short message ## describing the @code{help} command. ## +## @deftypefnx {Function File} {@var{text} =} help (@var{name}) +## Return the help text for the function, @var{name}. +## ## The help command can give you information about operators, but not the ## comma and semicolons that are used as command separators. To get help ## for those, you must type @kbd{help comma} or @kbd{help semicolon}. ## @seealso{doc, lookfor, which} -## @end deffn +## @end deftypefn -function help (name) +function varargout = help (name) if (nargin == 0) @@ -76,8 +79,12 @@ warning ("help: Texinfo formatting filter exited abnormally; raw Texinfo source of help text follows...\n"); endif - which (name); - printf ("\n%s\n%s", text, __additional_help_message__ ()); + if (nargout == 0) + which (name); + printf ("\n%s\n%s", text, __additional_help_message__ ()); + else + varargout = {text}; + endif else error ("help: invalid input\n");