view m-toolbox/classes/+utils/@helper/displayMethodInfo.m @ 52:daf4eab1a51e database-connection-manager tip

Fix. Default password should be [] not an empty string
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 07 Dec 2011 17:29:47 +0100
parents f0afece42f48
children
line wrap: on
line source

% 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