forked from wschwanghart/topotoolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
showmethods.m
executable file
·91 lines (72 loc) · 2.07 KB
/
showmethods.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
function showmethods(classname,showlink)
% displays class method names and H1 lines in the command line
%
% Syntax
%
% showmethods(classname)
% showmethods(classname,showlink)
%
% Description
%
% showmethods outputs a list of methods available for a specific class
% (e.g. GRIDobj) in the command window. Only the methods are listed
% that feature an H1 line, e.g., the first line of the help text block
% in a function.
%
% Input arguments
%
% classname string with class name (e.g. GRIDobj, FLOWobj)
% showlink false or true (default). If true, the function displays
% hyperlinks to the documentation.
%
%
% Example
%
% showmethods('GRIDobj')
%
% See also: methods, properties, class
%
% Author: Wolfgang Schwanghart (w.schwanghart[at]geo.uni-potsdam.de)
% Date: 5. December, 2017
narginchk(1,2)
if nargin == 1
showlink = true;
end
m = methods(classname);
C = cellfun(@(x) numel(x),m,'uniformoutput',true);
maxmethcharacter = max(C);
for r = 1:numel(m)
s = which([classname '/' m{r}]);
fileID = fopen(s,'r');
H1line = false;
try
while ~H1line && ~feof(fileID)
tline = fgetl(fileID);
if isempty(tline)
continue
end
if strcmp(tline(1),'%')
H1line = true;
end
end
if feof(fileID)
fclose(fileID);
continue
end
methodstr = m{r};
if numel(methodstr)<= maxmethcharacter
addblanks = repmat(' ',1,maxmethcharacter - numel(methodstr));
end
h1str = tline(2:end);
ix = strfind(h1str,' ');
h1str = h1str(ix(1)+1:end);
if ~showlink
disp([ upper(methodstr) addblanks ' : ' h1str]);
else
disp(['<a href="matlab: doc ' classname '/' methodstr '">' upper(methodstr) '</a>' addblanks ' : ' h1str]);
end
fclose(fileID);
catch
disp(m{r})
end
end