-
Notifications
You must be signed in to change notification settings - Fork 4
/
buildfile.m
41 lines (31 loc) · 1.19 KB
/
buildfile.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
function plan = buildfile
import matlab.buildtool.tasks.*;
plan = buildplan(localfunctions);
plan("clean") = CleanTask;
plan("test") = TestTask(TestResults=["test-results.pdf", "test-results.mat"]);
plan("markdown").Inputs = "**/*.mlx";
plan("markdown").Outputs = replace(plan("markdown").Inputs, ".mlx",".md");
plan("markdown").Outputs(end+1) = replace(plan("markdown").Inputs, ".mlx","_media");
plan("markdown").Outputs(end+1) = "mdOutputs.txt";
plan("jupyter").Inputs = "**/*.mlx";
plan("jupyter").Outputs = replace(plan("jupyter").Inputs, ".mlx",".ipynb");
end
function markdownTask(ctx)
% Generate markdown from all mlx files
mlxFiles = ctx.Task.Inputs.paths;
mdFiles = ctx.Task.Outputs(1).paths;
for idx = 1:numel(mlxFiles)
disp("Building markdown file from " + mlxFiles(idx))
export(mlxFiles(idx), mdFiles(idx), Run=true, EmbedImages=false);
end
writelines(ctx.Task.Outputs.paths,"mdOutputs.txt");
end
function jupyterTask(ctx)
% Generate jupyer notebooks from all mlx files
mlxFiles = ctx.Task.Inputs.paths;
ipynbFiles = ctx.Task.Outputs.paths;
for idx = 1:numel(mlxFiles)
disp("Building jupyter notebook from " + mlxFiles(idx))
export(mlxFiles(idx), ipynbFiles(idx), Run=true);
end
end