rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
htdoc.m
Go to the documentation of this file.
1 function htdoc(topic)
2 % function htdoc(topic)
3 % opens mtoc++ documentation in a browser
4 %
5 % Opens documentation generated by mtoc++ and doxygen in a browser. The
6 % directory where the HTML documentation is installed must be geiven by the
7 % 'DOXYGEN_DIR' environment variable. This can be set with
8 % @code
9 % setenv('DOXYGEN_DIR', '/path/to/doxygen/docu');
10 % @endcode
11 % in the 'startup.m' file, e.g.
12 %
13 % Parameters:
14 % topic: a string or an object describing for which the documentation
15 % site shall be opened.
16 
17 doxy_dir = getenv('DOXYGEN_DIR');
18 if isempty(doxy_dir) || ~exist(fullfile(doxy_dir, 'index.html'), 'file')
19  error('Environment variable DOXYGEN_DIR needs to be set to a valid documentation directory!');
20 end
21 
22 if ~ischar(topic)
23  classname = class(topic);
24 else
25  toks = get_tokens(topic);
26  classname = get_max_token(toks);
27 end
28 
29 [st, headertag] = system(['sed -ne ''s/^.*<\([^>]*\)>File List.*$/\1/p'' ', fullfile(getenv('DOXYGEN_DIR'), 'files.html')]);
30 headertag = ['<', headertag(1:end-1), '>'];
31 
32 [st, res]=system(['grep -l ''', headertag, classname, ' '' ', fullfile(getenv('DOXYGEN_DIR'), '*'), ' | head -1' ]);
33 if isempty(res)
34  funcname = regexprep(which(classname), '\\.m$', '');
35  funcname = strrep(funcname, [rbmatlabhome, filesep], '');
36  [st, res]=system(['grep -l ''', headertag, funcname, ' '' ', fullfile(getenv('DOXYGEN_DIR'), '*'), ' | head -1' ]);
37 end
38 if isempty(res)
39  web(fullfile(getenv('DOXYGEN_DIR'), 'index.html'), '-browser');
40  disp(['Could not find any entry for object ', classname, '.']);
41 end
42 
43 
44 web(res, '-browser');
45 
46 function toks = get_tokens(topic)
47  % function toks = get_tokens(topic)
48  % extracts possible tokens to search for in the documentation directory
49  toks = textscan(topic, '%s', 'Delimiter', './');
50  toks = toks{1};
51 
52 function mtok = get_max_token(toks)
53  % function mtok = get_max_token(toks)
54  % returns the token of maximum possible length.
55 
56  mtok_temp = toks{1};
57  for i= length(toks):-1:2
58  mtok = [mtok_temp, sprintf('.%s', toks{2:i})];
59  if ~isempty(which(mtok))
60  return;
61  end
62  end
63  mtok = toks{1};
function htdoc(topic)
opens mtoc++ documentation in a browser
Definition: htdoc.m:17
function rv = doxygen(param1, param2)
Here comes a short description text.
Definition: doxygen.m:17