generateDoc

PURPOSE ^

generateDoc uses m2html to create a set of html docs

SYNOPSIS ^

function generateDoc(pathname, graph)

DESCRIPTION ^

generateDoc uses m2html to create a set of html docs 
in the cba toolbox and place them in a directory called 'docs'.

 generateDoc(pathname, graph)

OPTIONAL INPUTS
 pathname  Path to folder to generate documents for
 graph     Generate function dependcy graph (Default = off) Set to 'on' 

If the directory 'docs' exists, the user will be prompted 
for notice that the contents of the directory will be 
replaced with a new set of generated docs.

This routine will exit if the user does not agree with this.
If the directory 'docs' does not exist, then it will be created.
 
generateDoc uses m2html, therefore m2html must be in the path.
m2html will be located in the cba toolbox and added to the path 
if not found on the path.

 Wing Choi 1/17/08
 Richard Que (8/06/2010)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function generateDoc(pathname, graph)
0002 %generateDoc uses m2html to create a set of html docs
0003 %in the cba toolbox and place them in a directory called 'docs'.
0004 %
0005 % generateDoc(pathname, graph)
0006 %
0007 %OPTIONAL INPUTS
0008 % pathname  Path to folder to generate documents for
0009 % graph     Generate function dependcy graph (Default = off) Set to 'on'
0010 %
0011 %If the directory 'docs' exists, the user will be prompted
0012 %for notice that the contents of the directory will be
0013 %replaced with a new set of generated docs.
0014 %
0015 %This routine will exit if the user does not agree with this.
0016 %If the directory 'docs' does not exist, then it will be created.
0017 %
0018 %generateDoc uses m2html, therefore m2html must be in the path.
0019 %m2html will be located in the cba toolbox and added to the path
0020 %if not found on the path.
0021 %
0022 % Wing Choi 1/17/08
0023 % Richard Que (8/06/2010)
0024 
0025 saveDir = pwd;
0026 %BUGFIX: Updated to work on Unix systems in addition to MS Windows
0027 %Do not remove this unless you've validated that your changes function
0028 %on Mac OS X and GNU/Linux
0029 if filesep == '/'
0030   cbaDir = filesep;
0031 else
0032   cbaDir = '';
0033 end
0034 dN = '';
0035 
0036 %locate the cbaToolbox from where matlab finds generateDoc
0037 mFilePath = mfilename('fullpath');
0038 cbaDir = mFilePath(1:end-length(mfilename)-1);
0039 cd(cbaDir);
0040 
0041 %if pathname was not an input argument
0042 currentDir = pwd;
0043 if(nargin<1)||isempty(pathname)
0044     % parse out the current dir name, not the entire path
0045     display (' ');
0046     display(strcat('Creating html docs for --> ' , ' ' , currentDir));
0047     reply = input('is this ok? y/n [n]: ', 's');
0048     if ((isempty(reply)) || (reply ~= 'y'))
0049         cd(saveDir);
0050         return;
0051     end
0052 else
0053     cbaDir = pathname;
0054 end
0055 
0056 %Get Directory Name
0057 remain = currentDir;
0058 while true
0059     [str, remain] = strtok(remain,filesep);
0060     if isempty(str), break; end
0061     dirName = str;
0062 end
0063 
0064 if (exist('m2html','file') ~= 2)
0065     disp('m2html not found, adding it to path');
0066     addpath(strcat(cbaDir,filesep,'external',filesep,'m2html')); %changed to reflect new folder structure
0067 end
0068 
0069 if (isdir('docs'))
0070     display ('The docs directory already exists')
0071     display ('I will remove the existing docs directory')
0072     display ('and replace its entire contents with newly')
0073     display ('generated html docs.')
0074     display (' ');
0075     reply = input('Do you want to replace the contents of the directory? y/n [n]: ', 's');
0076     if ((isempty(reply)) || (reply ~= 'y'))
0077         cd(saveDir);
0078         return;
0079     end
0080 end
0081 
0082 preDirName = cbaDir(1:end-length(dirName));
0083 if(nargin<2)||~strcmp(graph, 'on')
0084     dirNames = getDir(cbaDir,{'.svn','obsolete','docs','private','@template','toolboxes','internal','testing'});  
0085     for i=1:length(dirNames), dirNames{i} = strrep(dirNames{i},preDirName,''); end
0086     cd ..;
0087     m2html('mfiles',dirNames,'htmldir',strcat(dirName,filesep,'docs'),'recursive','off', 'global','on','template','frame', 'index','menu', 'globalHypertextLinks', 'on');
0088 else
0089     dirNames = getDir(cbaDir,{'.svn','obsolete','docs','private','@template','internal','toolboxes','testing'});
0090     for i=1:length(dirNames), dirNames{i} = strrep(dirNames{i},preDirName,''); end
0091 % go up one dir
0092     cd ..;
0093 % call m2html
0094     m2html('mfiles', dirNames, 'htmldir',strcat(dirName,filesep,'docs'),'recursive','off', 'global','on','template','frame', 'index','menu', 'globalHypertextLinks', 'on', 'graph', 'on');
0095 end
0096 % cd back to saveDir again
0097 cd(saveDir);
0098 
0099 function directories = getDir(directory,ignore)
0100 %Get list of directories beneath the specified directory
0101 directories = {directory};
0102 currDir = dir([directory,filesep,'*']);
0103 currDir = {currDir([currDir.isdir]).name};
0104 currDir =  currDir(~ismember(currDir,{'.','..',ignore{:}}));
0105 
0106 %Loop through the directory list and recursively call this function
0107 for i = 1:length(currDir)
0108     tmp = getDir([directory,filesep,currDir{i}],ignore);
0109     tmp = columnVector(tmp);
0110     directories = [directories; tmp(:)];
0111 end

Generated on Thu 21-Jun-2012 15:39:23 by m2html © 2003