reporting: option to suppress reporting output. closes #688

remove-priordens
Houtan Bastani 2014-07-25 14:38:30 +02:00
parent b0bd8d62c0
commit 7a529bc973
4 changed files with 35 additions and 13 deletions

View File

@ -30,6 +30,8 @@ function o = addPage(o, varargin)
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
np = length(o.pages) + 1;
fprintf(1, 'Adding Page: %d\n', np);
if o.showOutput
fprintf(1, 'Adding Page: %d\n', np);
end
o.pages{np} = page('orientation', o.orientation, 'paper', o.paper, varargin{:});
end

View File

@ -32,7 +32,7 @@ function o = compile(o, varargin)
opts.compiler = o.compiler;
opts.showReport = true;
opts.showOutput = true;
opts.showOutput = o.showOutput;
if nargin > 1
if round((nargin-1)/2) ~= (nargin-1)/2
@ -71,15 +71,28 @@ end
if isempty(opts.compiler)
if strncmp(computer, 'MACI', 4) || ~isempty(regexpi(computer, '.*apple.*', 'once'))
% Add most likely places for pdflatex to exist outside of default $PATH
[status, opts.compiler] = ...
system(['PATH=$PATH:/usr/texbin:/usr/local/bin:/usr/local/sbin;' ...
'which pdflatex'], echo);
if opts.showOutput
[status, opts.compiler] = ...
system(['PATH=$PATH:/usr/texbin:/usr/local/bin:/usr/local/sbin;' ...
'which pdflatex'], echo);
else
[status, opts.compiler] = ...
system('PATH=$PATH:/usr/texbin:/usr/local/bin:/usr/local/sbin;which pdflatex');
end
elseif strcmp(computer, 'PCWIN') || strcmp(computer, 'PCWIN64')
[status, opts.compiler] = system('findtexmf --file-type=exe pdflatex', echo);
if opts.showOutput
[status, opts.compiler] = system('findtexmf --file-type=exe pdflatex', echo);
else
[status, opts.compiler] = system('findtexmf --file-type=exe pdflatex');
end
middle = ' ';
opts.compiler = ['"' strtrim(opts.compiler) '"'];
else % gnu/linux
[status, opts.compiler] = system('which pdflatex', echo);
if opts.showOutput
[status, opts.compiler] = system('which pdflatex', echo);
else
[status, opts.compiler] = system('which pdflatex');
end
end
assert(status == 0, ...
'@report.compile: Could not find a tex compiler on your system');
@ -98,10 +111,11 @@ if status ~= 0
error(['@report.compile: There was an error in compiling ' rfn '.pdf.' ...
' ' compiler ' returned the error code: ' num2str(status)]);
end
fprintf(1, '\n\nDone.\n');
disp('Your compiled report is located here:');
disp([' ' pwd filesep rfn '.pdf']);
if o.showOutput || opts.showOutput
fprintf(1, 'Done.\n');
disp('Your compiled report is located here:');
disp([' ' pwd filesep rfn '.pdf']);
end
if opts.showReport && ~isoctave
open([pwd filesep rfn '.pdf']);
end

View File

@ -41,6 +41,7 @@ o.pages = {};
o.fileName = 'report.tex';
o.showDate = true;
o.compiler = '';
o.showOutput = true;
if nargin == 1
assert(isa(varargin{1}, 'report'), ['@report.report: with one arg, ' ...
@ -72,6 +73,7 @@ assert(ischar(o.title), '@report.report: title must be a string');
assert(ischar(o.fileName), '@report.report: fileName must be a string');
assert(ischar(o.compiler), '@report.report: compiler file must be a string');
assert(islogical(o.showDate), '@report.report: showDate must be either true or false');
assert(islogical(o.showOutput), '@report.report: showOutput must be either true or false');
assert(isfloat(o.margin) && o.margin > 0, '@report.report: margin must be a float > 0.');
valid_margin_unit = {'cm', 'in'};

View File

@ -80,7 +80,9 @@ fprintf(fid, '\\centering\n');
nps = length(o.pages);
for i=1:nps
fprintf(1, 'Writing Page: %d\n', i);
if o.showOutput
fprintf(1, 'Writing Page: %d\n', i);
end
o.pages{i}.write(fid, i);
end
@ -90,5 +92,7 @@ status = fclose(fid);
if status == -1
error('@report.write: closing %s\n', o.fileName);
end
disp('Finished Writing Report!');
if o.showOutput
disp('Finished Writing Report!');
end
end