This repository has been archived by the owner on Apr 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 167
/
Copy pathdocument_context.m
64 lines (57 loc) · 2 KB
/
document_context.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
62
63
64
function context = document_context(name, varargin)
% document_context Create report context structure
%
% Creates a new report context structure that can be used to generate
% report documents.
%
% Input:
% - name (string): Name of the report. Is used to name a directory where the report is stored in.
% - varargin[Title] (string): A human-friendly name of the report. May be more verbose than report name.
% - varargin[FigureEPS] (boolean): Should the report also generate formaps in Encapsulated PostScript (for LaTeX).
% - varargin[FigureRaw] (boolean): Should internal raw figures and data also be saved for future processing.
% - varargin[Standalone] (boolean): If true (default), the JavaScript and CSS resources are copied to the report.
% - varargin[Cache] (boolean): Should cache be used.
%
% Output:
% - context (structure): A report context structure.
%
title = name;
figure_eps = false;
figure_raw = false;
standalone = true;
cache = false;
for i = 1:2:length(varargin)
switch lower(varargin{i})
case 'title'
title = varargin{i+1};
case 'figureeps'
figure_eps = varargin{i+1};
case 'figureraw'
figure_raw = varargin{i+1};
case 'standalone'
standalone = varargin{i+1};
case 'cache'
cache = varargin{i+1};
otherwise
error(['Unknown switch ', varargin{i}, '!']) ;
end
end
context.root = fullfile(get_global_variable('directory'), 'reports', name);
context.images = fullfile(context.root, 'images');
context.raw = fullfile(context.root, 'raw');
context.data = fullfile(context.root, 'data');
context.exporteps = figure_eps;
context.exportraw = figure_raw;
context.standalone = standalone;
context.prefix = '';
context.imagesurl = 'images';
context.rawurl = 'raw';
context.dataurl = 'data';
context.title = title;
context.cache = cache;
mkpath(context.root);
mkpath(context.images);
mkpath(context.data);
mkpath(context.raw);
context.cachedir = fullfile(context.root, 'cache');
mkpath(context.cachedir);