diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/+utils/@helper/displayMethodInfo.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,64 @@
+% DISPLAYMETHODINFO displays the information about a method in the MATLAB browser.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% DESCRIPTION: DISPLAYMETHODINFO displays the information about a method
+%              in the MATLAB browser.
+%
+% CALL:        displayMethodInfo(className, methodName)
+%              displayMethodInfo(minfo)
+%
+% INPUTS:       className: String of the class.  For example 'ao'
+%              methodName: String of the method. For example 'sin'
+%                   minfo: an minfo object
+%
+% VERSION:     $Id: displayMethodInfo.m,v 1.4 2011/04/08 10:34:01 mauro Exp $
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+function varargout = displayMethodInfo(varargin)
+  
+  % Check the inputs
+  if nargin == 1 && isa(varargin{1}, 'minfo')
+    m = varargin{1};
+  else
+    if nargin ~= 2
+      error('### Unknown number of inputs');
+    elseif ~ischar(varargin{1}) && ~ischar(varargin{2})
+      error('### The inputs must be a class name and method name (both Strings)');
+    end
+    
+    className = varargin{1};
+    methodName = varargin{2};
+    
+    % Get method info object.
+    m = feval(sprintf('%s.getInfo', className), methodName);
+  end
+  
+  % 
+  txt = m.tohtml;
+  
+  % Workaround for the broken anchor tags in the HTML page.
+  % It is necessary to write the HTML page to disk.
+  className = m.mclass;
+  if isempty(className)
+    className = 'unknown';
+  end
+  dynamicHelpPath = fullfile(prefdir(), 'dynamicHelp', className);
+  
+  if ~exist(dynamicHelpPath, 'dir')
+    mkdir(dynamicHelpPath);
+  end
+
+  filename = sprintf('%s.html', m.mname);
+  
+  file = fullfile(dynamicHelpPath, filename);
+  
+  fid = fopen(file, 'w');
+  fwrite(fid, txt, 'char');
+  fclose(fid);
+  
+  web(file, '-new', '-noaddressbox');
+  
+  varargout = {};
+  
+end