forked from zprime/matlabfrag
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage.m
61 lines (55 loc) · 1.62 KB
/
package.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
%% Package matlabfrag for upload to the Mathworks File Exchange.
close all;
clear all;
clc;
addpath ./
%% Compile the figures
cd examples
run_all
%% Compile the documentation
if ispc
texpath = '';
elseif ismac
texpath = 'export PATH=$PATH:/usr/texbin:/usr/local/bin; ';
else
texpath = 'export PATH=$PATH:/usr/bin:/usr/local/bin; ';
end
for ii=1:3
[res,out] = system( sprintf('%spdflatex -interaction=nonstopmode -shell-escape userguide.tex', texpath ));
if res ~= 0
error('package:pdflatex','pdfLaTeX compilation failed with error:\n%s',out);
end
end
%% Remove GPL from userguide
% During submission to the file exchange, Mathworks search all the files
% for the string "GPL", because they require all files to be covered by the
% BSD license. Therefore, to prevent submission delays, all instances of
% "/Producer (dvips + GPL Ghostscript..." will have the GPL removed.
cd ..
fin = fopen(['examples',filesep,'userguide.pdf'],'r');
fout = fopen('userguide.pdf','w');
while( ~feof( fin ) )
line = fgets( fin );
line = regexprep(line,'GPL\sGhostscript','Ghostscript');
fwrite( fout, line );
end
fin = fclose(fin);
fout = fclose(fout);
%% Zip it up
zip('matlabfrag',{'matlabfrag.m',...
'epscompress.*',...
'userguide.pdf',...
['examples',filesep,'userguide.tex'],...
['examples',filesep,'testing.tex'],...
['examples',filesep,'ex*.m'],...
['examples',filesep,'comparison*.m'],...
['examples',filesep,'test*.m'] });
%% Clean up the output files
close all
cd examples
delete(['graphics',filesep,'*']);
rmdir('graphics');
delete('userguide.aux');
delete('userguide.log');
delete('userguide.out');
delete('userguide.toc');