0001 function generateDoc(pathname, graph)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 saveDir = pwd;
0026
0027
0028
0029 if filesep == '/'
0030 cbaDir = filesep;
0031 else
0032 cbaDir = '';
0033 end
0034 dN = '';
0035
0036
0037 mFilePath = mfilename('fullpath');
0038 cbaDir = mFilePath(1:end-length(mfilename)-1);
0039 cd(cbaDir);
0040
0041
0042 currentDir = pwd;
0043 if(nargin<1)||isempty(pathname)
0044
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
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'));
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
0092 cd ..;
0093
0094 m2html('mfiles', dirNames, 'htmldir',strcat(dirName,filesep,'docs'),'recursive','off', 'global','on','template','frame', 'index','menu', 'globalHypertextLinks', 'on', 'graph', 'on');
0095 end
0096
0097 cd(saveDir);
0098
0099 function directories = getDir(directory,ignore)
0100
0101 directories = {directory};
0102 currDir = dir([directory,filesep,'*']);
0103 currDir = {currDir([currDir.isdir]).name};
0104 currDir = currDir(~ismember(currDir,{'.','..',ignore{:}}));
0105
0106
0107 for i = 1:length(currDir)
0108 tmp = getDir([directory,filesep,currDir{i}],ignore);
0109 tmp = columnVector(tmp);
0110 directories = [directories; tmp(:)];
0111 end