rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
class_help.m
Go to the documentation of this file.
1 function class_help(classname_or_object, verbose)
2 % function class_help(classname_or_object, verbose)
3 % prints out class structure and documentation for a given classname or object
4 %
5 % The information printed by this function includes
6 % - classname,
7 % - names of superclasses,
8 % - parameters and
9 % - methods.
10 %
11 %
12 % Parameters:
13 % classname_or_object: Either a string holding the class name or a class
14 % object, for which information shall be printed.
15 % verbose : Integer triggering the amount of information which is
16 % printed.
17 % - '0' - print parameter and method names,
18 % - '1' - print parameter and method names (including
19 % inherited ones),
20 % - '2' - print parameter and method names and their
21 % documentation strings,
22 % - '3' - print parameter and method names and their
23 % documentation strings (including inherited
24 % parameters and methods).
25 
26 
27  if nargin == 1
28  verbose = false;
29  end
30  if ischar(classname_or_object)
31  metainfo = eval(['?',classname_or_object]);
32  else
33  metainfo = metaclass(classname_or_object);
34  end
35 
36  cn = metainfo.Name;
37 
38  if verbose > 1
39  helpstr = @(X) sprintf('\n %s',strrep(evalc(['help ', X]), sprintf('\n'), sprintf('\n ')));
40  else
41  helpstr = @(X) '';
42  end
43 
44  disp(['CLASS NAME: ', metainfo.Name]);
45  disp(' ')
46  disp(helpstr(cn));
47 
48 
49  inherits = char( cellfun(@(X) [X.Name, ' '], ...
50  metainfo.SuperClasses, ...
51  'UniformOutput', false));
52  disp(['Inherits from: ' inherits]);
53 
54 
55  if verbose == 0 || verbose == 2
56  meths = metainfo.Methods(...
57  cellfun(@(X) strcmp(X.DefiningClass.Name,cn)==1, metainfo.Methods, 'UniformOutput',true));
58  props = metainfo.Properties(...
59  cellfun(@(X) strcmp(X.DefiningClass.Name,cn)==1, metainfo.Properties, 'UniformOutput',true));
60  else
61  meths = metainfo.Methods;
62  props = metainfo.Properties;
63  end
64 
65  proplist = cellfun(@(X) sprintf('%s%s', ...
66  X.Name, ...
67  helpstr([cn, '.', X.Name])), ...
68  props, ...
69  'UniformOutput', false);
70 
71  disp(' ')
72  disp(' ')
73  disp('PROPERTIES');
74  disp('==========');
75  disp(' ')
76 
77  cellfun(@disp, proplist);
78 
79  methlist = cellfun(@(X) sprintf('%s%s', ...
80  X.Name, ...
81  helpstr([cn, '.', X.Name])), ...
82  meths, ...
83  'UniformOutput', false);
84 
85  disp(' ')
86  disp(' ')
87  disp('METHODS');
88  disp('==========');
89  disp(' ')
90 
91  cellfun(@disp, methlist);
92 end
93 
function class_help(classname_or_object, verbose)
prints out class structure and documentation for a given classname or object
Definition: class_help.m:17
function r = verbose(level, message, messageId)
This function displays messages depending on a message-id and/or a level. Aditionally you can set/res...
Definition: verbose.m:17