%function ReadmeGen(FilesPath,ViewRes,Author,Dates) %This m-file is used to automatically generate a readme html file. %Syntax: % ReadmeGen(FilesPath); % ReadmeGen(FilsePath, ViewRes); % ReadmeGen(FilsePath, ViewRes, Author); % ReadmeGen(FilsePath, ViewRes, Author, Dates); % FilesPath: a string contain the name of the directory you want to % documnet. E.g. 'D:\Mylab' % ViewRes: when set as 1 or '-s', show the resulting Readme.htm using IE. % Defualt is ViewRes=1. % Author: name of the Author. E.g. 'Donald E. Knuth'. % Default is Tony X. Han. :) % Dates: a string containing the date. % Default is Today's date. % For Example: % ReamenGen Mylab\FFT -s Cooley 1965 % will generate a Readme html for directory FFT. With year 1965, copyright Cooley. % % Copyright (c) Tony X. Han 02/18/2006 % Please send email to: xuhan-AT-ifp.uiuc.edu to report bugs. function ReadmeGen(FilesPath,ViewRes,Author,Dates) IeFullPath= 'C:\Progra~1\Intern~1\iexplore.exe'; %The default path of IE for viewing the results. If your IE is not %installed in above directory, please revise. if nargin >4 error('Too many parameters'); return; elseif nargin<1 end switch nargin case 0 error('Please at least specify the directory that you want to generate Readme'); return; case 1 ViewRes=1; % show Resulting html by default. Author= 'Tony X. Han'; Dates= date; case 2 Author= 'Tony X. Han'; Dates= date; case 3 Dates= date; case 4 ; otherwise error('Too many parameters'); return; end [pathstr,Title,CurExt,versn] = fileparts(FilesPath); ReadmeName=[FilesPath '\' Title '_Readme.htm']; Mfile=[FilesPath '\*.m']; FileStruct= dir(Mfile); [FileNum temp]= size(FileStruct); FileCounter= 0; [fid,message]= fopen(ReadmeName, 'w+'); if fid== -1 error(message); return end Write_html_Header(fid, Title, Author, Dates); PathOrig=pwd; cd(FilesPath); for k= 1:FileNum CurFileName= FileStruct(k).name; [pathstr,name,CurExt,versn] = fileparts(CurFileName); Write_html_entry(fid,[name CurExt],CurFileName); end cd(PathOrig); %change back; Write_html_Tail(fid, Title, Author, Dates); fclose(fid); %keyboard; if ViewRes==1 | ViewRes=='-s' %view the resulting .htm file by ie. if isempty(find(ReadmeName==':')) %relative path doesn't have ':' inside. convert to absolut path. PathHead=pwd; ReadmeName= [PathHead '\' ReadmeName]; end strCommand=['!' IeFullPath ' ' ReadmeName '&']; eval(strCommand); end return; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function Write_html_Header(fid, Title, Author, Dates) Newline=sprintf('\n'); Title_s= ['Matlab file list for ' Title]; s=''; fprintf(fid,'%s\n',s); s= ['
'; fprintf(fid,'%s\n',s); s='
Copyright (c) ' Author ' ' Dates]; fprintf(fid,'%s\n',s); s='
'; fprintf(fid,'%s\n',s); return; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function Write_html_entry(fid,name,FullName); s=['' name ''];
fprintf(fid,'%s\n',s);
s='