Mercurial > hg > ltpda
comparison m-toolbox/classes/+utils/@helper/displayMethodInfo.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % DISPLAYMETHODINFO displays the information about a method in the MATLAB browser. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: DISPLAYMETHODINFO displays the information about a method | |
5 % in the MATLAB browser. | |
6 % | |
7 % CALL: displayMethodInfo(className, methodName) | |
8 % displayMethodInfo(minfo) | |
9 % | |
10 % INPUTS: className: String of the class. For example 'ao' | |
11 % methodName: String of the method. For example 'sin' | |
12 % minfo: an minfo object | |
13 % | |
14 % VERSION: $Id: displayMethodInfo.m,v 1.4 2011/04/08 10:34:01 mauro Exp $ | |
15 % | |
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
17 | |
18 function varargout = displayMethodInfo(varargin) | |
19 | |
20 % Check the inputs | |
21 if nargin == 1 && isa(varargin{1}, 'minfo') | |
22 m = varargin{1}; | |
23 else | |
24 if nargin ~= 2 | |
25 error('### Unknown number of inputs'); | |
26 elseif ~ischar(varargin{1}) && ~ischar(varargin{2}) | |
27 error('### The inputs must be a class name and method name (both Strings)'); | |
28 end | |
29 | |
30 className = varargin{1}; | |
31 methodName = varargin{2}; | |
32 | |
33 % Get method info object. | |
34 m = feval(sprintf('%s.getInfo', className), methodName); | |
35 end | |
36 | |
37 % | |
38 txt = m.tohtml; | |
39 | |
40 % Workaround for the broken anchor tags in the HTML page. | |
41 % It is necessary to write the HTML page to disk. | |
42 className = m.mclass; | |
43 if isempty(className) | |
44 className = 'unknown'; | |
45 end | |
46 dynamicHelpPath = fullfile(prefdir(), 'dynamicHelp', className); | |
47 | |
48 if ~exist(dynamicHelpPath, 'dir') | |
49 mkdir(dynamicHelpPath); | |
50 end | |
51 | |
52 filename = sprintf('%s.html', m.mname); | |
53 | |
54 file = fullfile(dynamicHelpPath, filename); | |
55 | |
56 fid = fopen(file, 'w'); | |
57 fwrite(fid, txt, 'char'); | |
58 fclose(fid); | |
59 | |
60 web(file, '-new', '-noaddressbox'); | |
61 | |
62 varargout = {}; | |
63 | |
64 end |