Robochameleon  v1.0
robohelp.m
Go to the documentation of this file.
1 
2 function robohelp(varargin)
3  roboRoot = getpref('robochameleon','roboRootFolder','NULL');
4  if strcmp(roboRoot,'NULL')
5  robolog('Run "robochameleon" to initialize the robochameloen path.', 'ERR');
6  end
7 
8  excludePaths = '\.git|user manual'; %Regexp format
9  if ~isempty(varargin)
10  searchTerm = varargin{1};
11  searchTerm = strrep(searchTerm, '*', '.*'); % * match all, shell style
12  classOnly = 0;
13  if length(varargin) > 1
14  if strcmp(varargin{2}, 'c')
15  %Search only for classes
16  classOnly = 1;
17  end
18  end
19  fileList = getAllFiles(roboRoot);
20  fullName = '';
21  for i=1:length(fileList)
22  [fpath, namee] = fileparts(fileList{i});
23  if isempty(regexp(fpath, excludePaths, 'once'))
24  if ~isempty(regexp(namee, searchTerm, 'once'))
25  if classOnly && ~(exist(namee, 'class') == 8)
26  continue;
27  end
28  if isempty(fullName) || strcmp(namee, searchTerm)
29  % Do this on the first match and also if the file name matches COMPLETELY the
30  % searchTerm
31  fullName = namee;
32  elseif isempty(regexp(searchTerm, '[tTest]', 'once')) && ...
33  ~isempty(regexp(namee, '[tT]est', 'once'))
34  % This will avoid the unit testers to match as duplicate, but if we are looking for a
35  % unit tester it will fail if there are multiple matches of the search term.
36  continue;
37  else
38  robolog('Search query matches multiple classes/files. Ignoring %s.', 'WRN', namee);
39  end
40  end
41  end
42  end
43  robolog('Opening documentation for class %s', fullName);
44  if isempty(fullName)
45  robolog('Search query didn''t match anything.', 'ERR');
46  end
47  fullNameParsed = regexprep(fullName, '([A-Z_])', '_$1');
48  fullNameParsed = lower(fullNameParsed);
49  if exist(fullName, 'class') == 8
50  url = sprintf('%s/doc/user manual/html/class%s.html', roboRoot, fullNameParsed);
51  else
52  url = sprintf('%s/doc/user manual/html/%s_8m.html', roboRoot, fullNameParsed);
53  end
54  else
55  url = sprintf('%s/doc/user manual/html/index.html', roboRoot);
56  end
57 
58  web(url, '-browser');
59 end
Superclass: basic building block to hold functions.
Definition: unit.m:27
function robolog(in msg, in varargin)
This function allows the user to print log messages in a standard way.
function robochameleon(in varargin)
Add robochameleon related directories to the MATLAB path.
function robohelp(in varargin)
Open the robochameleon help main page or a class/function documentation in the browser.