rbmatlab 0.10.01
general/help/class_help.m
Go to the documentation of this file.
00001 function class_help(classname_or_object, verbose)
00002 % function class_help(classname_or_object, verbose)
00003 % prints out class structure and documentation for a given classname or object
00004 %
00005 % The information printed by this function includes
00006 %   - classname,
00007 %   - names of superclasses,
00008 %   - parameters and
00009 %   - methods.
00010 %
00011 %
00012 % Parameters:
00013 %   classname_or_object: Either a string holding the class name or a class
00014 %                        object, for which information shall be printed.
00015 %   verbose            : Integer triggering the amount of information which is
00016 %                        printed.
00017 %                        - '0' - print parameter and method names,
00018 %                        - '1' - print parameter and method names (including
00019 %                                inherited ones),
00020 %                        - '2' - print parameter and method names and their
00021 %                                documentation strings,
00022 %                        - '3' - print parameter and method names and their
00023 %                                documentation strings (including inherited
00024 %                                parameters and methods).
00025 
00026 
00027   if nargin == 1
00028     verbose = false;
00029   end
00030   if ischar(classname_or_object)
00031     metainfo = eval(['?',classname_or_object]);
00032   else
00033     metainfo = metaclass(classname_or_object);
00034   end
00035 
00036   cn = metainfo.Name;
00037 
00038   if verbose > 1
00039     helpstr = @(X) sprintf('\n    %s',strrep(evalc(['help ', X]), sprintf('\n'), sprintf('\n    ')));
00040   else
00041     helpstr = @(X) '';
00042   end
00043 
00044   disp(['CLASS NAME: ', metainfo.Name]);
00045   disp(' ')
00046   disp(helpstr(cn));
00047 
00048 
00049   inherits = char( cellfun(@(X) [X.Name, ' '], ...
00050                            metainfo.SuperClasses, ...
00051                            'UniformOutput', false));
00052   disp(['Inherits from: ' inherits]);
00053 
00054 
00055   if verbose == 0 || verbose == 2
00056     meths = metainfo.Methods(...
00057               cellfun(@(X) strcmp(X.DefiningClass.Name,cn)==1, metainfo.Methods, 'UniformOutput',true));
00058     props = metainfo.Properties(...
00059               cellfun(@(X) strcmp(X.DefiningClass.Name,cn)==1, metainfo.Properties, 'UniformOutput',true));
00060   else
00061     meths = metainfo.Methods;
00062     props = metainfo.Properties;
00063   end
00064 
00065   proplist = cellfun(@(X) sprintf('%s%s', ...
00066                                   X.Name, ...
00067                                   helpstr([cn, '.', X.Name])), ...
00068                      props, ...
00069                      'UniformOutput', false);
00070 
00071   disp(' ')
00072   disp(' ')
00073   disp('PROPERTIES');
00074   disp('==========');
00075   disp(' ')
00076 
00077   cellfun(@disp, proplist);
00078 
00079   methlist = cellfun(@(X) sprintf('%s%s', ...
00080                                   X.Name, ...
00081                                   helpstr([cn, '.', X.Name])), ...
00082                      meths, ...
00083                      'UniformOutput', false);
00084 
00085   disp(' ')
00086   disp(' ')
00087   disp('METHODS');
00088   disp('==========');
00089   disp(' ')
00090 
00091   cellfun(@disp, methlist);
00092 end
00093 
 All Classes Namespaces Files Functions Variables