|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function [alltext, allvars] = gethelpvar( filename, varlist ) |
|
|
|
|
|
if nargin < 1 |
|
|
help gethelpvar; |
|
|
return; |
|
|
end; |
|
|
|
|
|
|
|
|
|
|
|
fid = fopen( filename, 'r'); |
|
|
if fid == -1 |
|
|
error('File not found'); |
|
|
end; |
|
|
|
|
|
cont = 1; |
|
|
|
|
|
|
|
|
str = fgets( fid ); |
|
|
|
|
|
if str(1) ~= '%', str = fgets( fid ); end; |
|
|
|
|
|
|
|
|
|
|
|
maindescription = 1; |
|
|
varname = []; |
|
|
oldvarname = []; |
|
|
vartext = []; |
|
|
newvar = 0; |
|
|
allvars = {}; |
|
|
alltext = {}; |
|
|
indexout = 1; |
|
|
|
|
|
while (str(1) == '%') |
|
|
str = deblank(str(2:end-1)); |
|
|
|
|
|
|
|
|
newvar = 0; |
|
|
str = deblank2(str); |
|
|
|
|
|
if ~isempty(str) |
|
|
|
|
|
|
|
|
|
|
|
i2d = findstr(str, ':'); |
|
|
newtitle = 0; |
|
|
if ~isempty(i2d) |
|
|
i2d = i2d(1); |
|
|
switch lower(str(1:i2d)) |
|
|
case { 'usage:' 'authors:' 'author:' 'notes:' 'note:' 'input:' ... |
|
|
'inputs:' 'outputs:' 'output' 'example:' 'examples:' 'see also:' }, newtitle = 1; |
|
|
end; |
|
|
if (i2d == length(str)) & (str(1) ~= '%'), newtitle = 1; end; |
|
|
end; |
|
|
if newtitle |
|
|
tilehtml = str(1:i2d); |
|
|
newtitle = 1; |
|
|
oldvarname = varname; |
|
|
oldvartext = vartext; |
|
|
if i2d < length(str) |
|
|
|
|
|
vartext = str(i2d+1:end); |
|
|
else vartext = []; |
|
|
end; |
|
|
varname = []; |
|
|
else |
|
|
|
|
|
|
|
|
|
|
|
[tok1 strrm] = strtok( str ); |
|
|
[tok2 strrm] = strtok( strrm ); |
|
|
|
|
|
if ~isempty(tok2) & ( isequal(tok2,'-') | isequal(tok2,'=')) |
|
|
newvar = 1; |
|
|
oldvarname = varname; |
|
|
oldvartext = vartext; |
|
|
varname = tok1; |
|
|
strrm = deblank(strrm); |
|
|
strrm = deblank(strrm(end:-1:1)); |
|
|
|
|
|
strrm = strrm(end:-1:1); |
|
|
vartext = strrm; |
|
|
else |
|
|
|
|
|
str = deblank(str); |
|
|
str = deblank(str(end:-1:1)); |
|
|
|
|
|
str = str(end:-1:1); |
|
|
if isempty(vartext) |
|
|
vartext = str; |
|
|
else |
|
|
if ~isempty(varname) |
|
|
vartext = [ vartext 10 str]; |
|
|
else |
|
|
if length(vartext)>3 & all(vartext( end-2:end) == '.') |
|
|
vartext = [ deblank2(vartext(1:end-3)) 10 str]; |
|
|
else |
|
|
vartext = [ vartext 10 str]; |
|
|
end; |
|
|
end; |
|
|
end; |
|
|
end; |
|
|
newtitle = 0; |
|
|
end; |
|
|
|
|
|
|
|
|
str = fgets( fid ); |
|
|
|
|
|
|
|
|
|
|
|
if str(1) ~= '%' |
|
|
if ~newtitle |
|
|
if ~isempty(oldvarname) |
|
|
allvars{indexout} = oldvarname; |
|
|
alltext{indexout} = oldvartext; |
|
|
indexout = indexout + 1; |
|
|
|
|
|
|
|
|
else |
|
|
if ~isempty(oldvartext) |
|
|
|
|
|
end; |
|
|
end; |
|
|
newvar = 1; |
|
|
oldvarname = varname; |
|
|
oldvartext = vartext; |
|
|
end; |
|
|
end; |
|
|
|
|
|
|
|
|
|
|
|
if newvar | newtitle |
|
|
if maindescription |
|
|
if ~isempty(oldvartext) |
|
|
maintext = oldvartext; |
|
|
maindescription = 0; |
|
|
functioname = oldvarname( 1:findstr( oldvarname, '()' )-1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end; |
|
|
elseif ~isempty(oldvarname) |
|
|
allvars{indexout} = oldvarname; |
|
|
alltext{indexout} = oldvartext; |
|
|
indexout = indexout + 1; |
|
|
|
|
|
|
|
|
else |
|
|
if ~isempty(oldvartext) |
|
|
|
|
|
end; |
|
|
end; |
|
|
end; |
|
|
|
|
|
|
|
|
|
|
|
if newtitle |
|
|
|
|
|
if str(1) ~= '%' |
|
|
|
|
|
end; |
|
|
oldvarname = []; |
|
|
oldvartext = []; |
|
|
end; |
|
|
else |
|
|
str = fgets( fid ); |
|
|
end; |
|
|
end; |
|
|
fclose( fid ); |
|
|
|
|
|
|
|
|
|
|
|
for index = 1:length(allvars) |
|
|
if allvars{index}(1) == '''', allvars{index} = eval( allvars{index} ); end; |
|
|
end; |
|
|
|
|
|
if exist('varlist') == 1 |
|
|
if ~iscell(varlist), varlist = { varlist }; end; |
|
|
newtxt = mat2cell(zeros(length(varlist), 1), length(varlist), 1); |
|
|
for index = 1:length(varlist) |
|
|
loc = strmatch( varlist{index}, allvars); |
|
|
if ~isempty(loc) |
|
|
newtxt{index} = alltext{loc(1)}; |
|
|
else |
|
|
disp([ 'warning: variable ''' varlist{index} ''' not found']); |
|
|
newtxt{index} = ''; |
|
|
end; |
|
|
end; |
|
|
alltext = newtxt; |
|
|
end; |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function str = deblank2( str ); |
|
|
str = deblank(str(end:-1:1)); |
|
|
str = deblank(str(end:-1:1)); |
|
|
return; |
|
|
|
|
|
function strout = formatstr( str, refcall ); |
|
|
[tok1 strrm] = strtok( str ); |
|
|
strout = []; |
|
|
while ~isempty(tok1) |
|
|
tokout = functionformat( tok1, refcall ); |
|
|
if isempty( strout) |
|
|
strout = tokout; |
|
|
else |
|
|
strout = [strout ' ' tokout ]; |
|
|
end; |
|
|
[tok1 strrm] = strtok( strrm ); |
|
|
end; |
|
|
return; |
|
|
|
|
|
function tokout = functionformat( tokin, refcall ); |
|
|
tokout = tokin; |
|
|
[test, realtokin, tail] = testfunc1( tokin ); |
|
|
if ~test, [test, realtokin, tail] = testfunc2( tokin ); end; |
|
|
if test |
|
|
i1 = findstr( refcall, '%s'); |
|
|
i2 = findstr( refcall(i1(1):end), ''''); |
|
|
if isempty(i2) i2 = length( refcall(i1(1):end) )+1; end; |
|
|
filename = [ realtokin refcall(i1+2:i1+i2-2)]; |
|
|
if exist( filename ) |
|
|
tokout = sprintf( [ '<A HREF="' refcall '">%s</A>' tail ' ' ], realtokin, realtokin ); |
|
|
end; |
|
|
end; |
|
|
return; |
|
|
|
|
|
function [test, realtokin, tail] = testfunc1( tokin ) |
|
|
test = 0; realtokin = ''; tail = ''; |
|
|
if ~isempty( findstr( tokin, '()' ) ) |
|
|
realtokin = tokin( 1:findstr( tokin, '()' )-1); |
|
|
if length(realtokin) < (length(tokin)-2) tail = tokin(end); else tail = []; end; |
|
|
test = 1; |
|
|
end; |
|
|
return; |
|
|
|
|
|
function [test, realtokin, tail] = testfunc2( tokin ) |
|
|
test = 0; realtokin = ''; tail = ''; |
|
|
if all( upper(tokin) == tokin) |
|
|
if tokin(end) == ',' |
|
|
realtokin = tokin(1:end-1); |
|
|
tail = ','; |
|
|
else |
|
|
realtokin = tokin; |
|
|
end; |
|
|
testokin = realtokin; |
|
|
testokin(findstr(testokin, '_')) = 'A'; |
|
|
testokin(findstr(testokin, '2')) = 'A'; |
|
|
if all(double(testokin) > 64) & all(double(testokin) < 91) |
|
|
test = 1; |
|
|
end; |
|
|
realtokin = lower(realtokin); |
|
|
end; |
|
|
return; |
|
|
|