ita_generate_documentation.m 3.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
function ita_generate_documentation(varargin)
%ITA_GENERATE_DOCUMENTATION - Generate Toolbox Help
%  This function automatically generated the html help used for the Toolbox
%
%   See also help, doc, helpdesk, ita_toolbox_setup.
%
%   Reference page in Help browser
%        <a href="matlab:doc ita_generate_documentation">doc ita_generate_documentation</a>

% <ITA-Toolbox>
% This file is part of the application HTMLhelp for the ITA-Toolbox. All rights reserved.
% You can find the license for this m-file in the application folder.
% </ITA-Toolbox>

%
% Author: Pascal Dietrich -- Email: pdi@akustik.rwth-aachen.de
% Created:  17-Apr-2009
18
% Edited: 18-May-2012 Tumbr�gel
19 20 21 22 23 24


% pdi not for preferences
sArgs = struct('rootpath',ita_toolbox_path);
sArgs = ita_parse_arguments(sArgs,varargin);

25
currentDir = pwd;
26

27
%generate helpbrowser html files - Tumbr�gel 05/2012:
28 29
ita_generate_helpOverview(sArgs.rootpath); 

30
cd(sArgs.rootpath)
31
%% Get folders for m2html
32 33 34 35 36 37 38 39 40 41 42
ignoreList  = {'.svn', ...
               '.git', ...
               'private', ...
               'tmp', ...
               'prop-base', ...
               'props', ...
               'text-base', ...
               'template', ...
               'doc', ...
               'GuiCallbacks', ...
               'external_packages', ...
43 44
               'ExternalPackages', ...
               'helpers'};
45
pathStr = genpath(sArgs.rootpath);
46
prefixToolbox = fliplr(strtok(fliplr(sArgs.rootpath),filesep)); %get Toolbox folder name
47 48 49

outpathStr  = [];
outpathList = [];
Marco Berzborn's avatar
Marco Berzborn committed
50
tokenIdx    = [0 strfind(pathStr,pathsep)];
51 52 53 54 55

for idx=1:(length(tokenIdx)-1)
   tokenCell{idx} = pathStr(tokenIdx(idx)+1:tokenIdx(idx+1)-1); %get single folder name
   isIgnore = false;
   for ignIdx = 1:length(ignoreList)
Marco Berzborn's avatar
Marco Berzborn committed
56
       foundIdx     = strfind(tokenCell{idx},ignoreList{ignIdx}); %folder in ignore list?
57 58 59
       isIgnore     = ~isempty(foundIdx) || isIgnore;
    end
   if ~isIgnore %add string token
60
       outpathStr   = [outpathStr,pathsep,tokenCell{idx}]; %#ok<*AGROW>
Marco Berzborn's avatar
Marco Berzborn committed
61
       idxITA = strfind(tokenCell{idx},prefixToolbox); %pdi
62
       outpathList  = [outpathList; {tokenCell{idx}(idxITA:end)}]; % make path relative
63 64 65 66 67 68 69 70 71 72 73
   end  
end

% delete old one first
graphInst = ita_preferences('isGraphVizInstalled');

if ischar(graphInst), graphInst = str2double(graphInst); end;

%% ignorelist -- doc - guicallbacks - externalpackages
if graphInst
    graphState = 'on';
74
    disp('Generating with GraphViz')
75 76 77
else
    graphState = 'off';
end
Marco Berzborn's avatar
Marco Berzborn committed
78 79
htmlFolder = fullfile(sArgs.rootpath, 'HTML');
docFolder = fullfile(htmlFolder, 'doc');
80 81
% cd required for m2html
cd ..
82 83 84 85 86 87 88
tic
m2html('mfiles',outpathList, 'htmldir',docFolder, 'recursive','off', 'source','off', 'syntaxHighlighting','on', ...
    'global','on', 'globalHypertextLinks','on', 'todo','on', ...
    'verbose','on','template','blue', 'indexFile','index', 'graph',graphState);
toc

%% Build search database for helpdesk
89 90
% switching to basic rendering to fix bug with builddocsearchdb
webutils.htmlrenderer('basic');
Marco Berzborn's avatar
Marco Berzborn committed
91 92 93
% MATLAB requires the html files to be in its search path
addpath(htmlFolder, docFolder);
savepath;
94
% switching seems to take a while sometimes
95
pause(1);
96
if nargin == 0
Marco Berzborn's avatar
Marco Berzborn committed
97
    builddocsearchdb(htmlFolder); %generate help search
98 99
    rehash toolboxcache
end
100 101 102
% switch back to standard renderer
webutils.htmlrenderer('default');

103
ita_verbose_info('Please restart MATLAB if the MATLAB ITA Toolbox entry does not show in the documentation browser.',0);
104 105
%% Go back to the last working directory
cd(currentDir)