1 ## Copyright (C) 2008 Muthiah Annamalai <muthiah.annamalai@mavs.uta.edu>
3 ## This program is free software; you can redistribute it and/or modify it under
4 ## the terms of the GNU General Public License as published by the Free Software
5 ## Foundation; either version 3 of the License, or (at your option) any later
8 ## This program is distributed in the hope that it will be useful, but WITHOUT
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 ## You should have received a copy of the GNU General Public License along with
14 ## this program; if not, see <http://www.gnu.org/licenses/>.
17 ## @deftypefn{Function File} infoskeleton(@var{prototype}, @var{index_str}, @var{see_also})
18 ## Generate TeXinfo skeleton documentation of @var{prototype}.
20 ## Optionally @var{index_str} and @var{see_also} can be specified.
22 ## Usage of this function is typically,
24 ## infoskeleton('[V,Q] = eig( A )','linear algebra','eigs, chol, qr, det')
29 function infoskeleton( prototype , index_str, seealso)
31 ## FIXME: add placeholders for math TeX code, examples etc.
46 ## try to parse the function prototype
48 ## function retval = fname ( arg1, arg2, etc )"
50 prototype = strtrim( prototype );
51 idx = strfind( prototype, "function" );
52 if ( !isempty( idx ) )
53 prototype(idx:idx+7) = "";
56 idx = strfind( prototype, "=" );
59 retval = strtrim ( prototype( 1 : idx(1)-1 ) );
60 prototype = prototype ( idx(1) + 1: end );
64 idx = strfind( prototype, "(" );
67 fname = strtrim( prototype(1:idx(1)-1) );
68 prototype = prototype(idx(1) + 1:end);
71 ## next time, use strtok() very easy & simple
74 idx = strfind( prototype , "," );
75 if ( !isempty( idx ) )
77 for pos=1:length( idx )
78 args{ pos } = strtrim ( prototype(prev( pos )+1 :idx(pos)-1) );
80 prototype = prototype(idx(end) + 1:end);
83 idx = strfind( prototype, ")" );
84 if ( !isempty( idx ) )
85 lvar = strtrim ( prototype(1:idx(1)-1) );
86 if ( length( lvar ) > 0 )
87 args{ pos + 1 } = lvar;
93 fprintf("## -*- texinfo -*-\n")
94 if ( length( retval ) > 0 )
95 fprintf("## @deftypefn{Function File} {@var{%s} = } %s (", ...
98 fprintf("## @deftypefn{Function File} { } %s (", ...
103 for pos = 1:length(args)-1
104 fprintf(" %s,", args{pos} );
106 if ( length(args) > 0 )
107 fprintf(" %s ) \n", args{pos+1} );
109 fprintf("## @cindex %s \n",index_str);
110 fprintf("## The function %s calculates where",fname );
112 for pos = 1:length(args)-1
113 fprintf(" @var{%s} is ,", args{pos} );
115 if ( length(args) > 0 )
116 fprintf(" @var{%s} is .\n", args{pos+1} );
119 fprintf("## @example\n");
121 fprintf("## @end example\n");
123 fprintf("## @seealso{%s}\n",seealso);
124 fprintf("## @end deftypefn\n");
127 %!demo infoskeleton( ' [x,y,z]=infoskeleton(func , z , z9 , jj, fjh, x) ')
128 %!demo infoskeleton('[V,Q] = eig( A )','linear algebra','eigs, chol, qr, det')
129 %!demo infoskeleton( 'function [x,y,z] = indian_languages ( x) ')