-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.jl
44 lines (35 loc) · 1.23 KB
/
run.jl
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
using Franklin
using Literate
using Tar
process_literate(fstring) = replace(fstring, "_tutorials" => ".")
function build_tutorials(path = "_tutorials", tarpath = "__site/assets/"; ignore = [])
# create directory to store outputs
outpath = "__generated"
isdir(outpath) || mkpath(outpath)
# copy tomls
for file in ["Project.toml", "Manifest.toml", "Artifacts.toml"]
cp(joinpath(path, file), joinpath(outpath, file); force = true)
end
# copy src
isdir(joinpath(outpath, "src")) || mkpath(joinpath(outpath, "src"))
cp(joinpath(path, "src"), joinpath(outpath, "src"); force = true)
# copy tutorials
for file in readdir(path)
_, ext = splitext(file)
(ext == ".jl") && (file ∉ ignore) || continue
Literate.script(joinpath(path, file), outpath;
execute = false, preprocess = process_literate)
end
# put it all together
isdir(tarpath) || mkpath(tarpath)
Tar.create(outpath, joinpath(tarpath, "tutorials.tar.gz"))
end
function preview(; eval_all = false)
build_tutorials(ignore = ["training.jl"])
serve(single = true)
serve(eval_all = eval_all)
end
function deploy()
build_tutorials(ignore = ["training.jl"])
optimize()
end