from
M2TEX
by Andreas
Extracts comments from m-files to create Contents.m and TeX-file.
|
| m2tex(wd)
|
function m2tex(wd)
% M2TEX creates Contents.m and LaTeX report from m-file comments.
%
% M2TEX(DIR) extracts the help comments of the m-files in the directory
% DIR. It creates a Contents.m for use with MATLAB's help function and a
% file ref.tex, that can be processed using LaTeX.
%
% For M2TEX to work, comments should follow this example:
%
% function y = foo(bar)
% % FOO bars the gnus
% % and has two lines of short comments
% %
% % Here comes the long comment
% % Syntax: FOO(BAR)
% %
% % This function computes the foo-value ...
%
% The formatting follows the standard rules used by Mathworks for their
% m-files, with one important exception:
%
% M2TEX supports more than one header line (for longer short comments ;-)).
% However, for this feature to work, it is necessary to separate the main
% comment from the header by an empty line only containing one %!
% Changes:
% aha, 26-may-04, original version
if nargin<1
wd=pwd;
end
owd = pwd;
cd(wd);
if exist('./Contents.m','file')
suc = copyfile('Contents.m','Contents.m~','f');
delete('Contents.m')
if ~(suc), error('Could not backup Contents.m!'), end
end
if exist('./ref.tex','file')
suc = copyfile('ref.tex','ref.tex~','f');
if ~(suc), error('Could not backup ref.tex!'), end
end
fn = dir('*.m');
perl('m2tex.pl',fn.name)
cd(owd)
|
|
Contact us at files@mathworks.com