-
Notifications
You must be signed in to change notification settings - Fork 157
/
generate.jl
39 lines (32 loc) · 1005 Bytes
/
generate.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
# helper
function runcommand(cmd)
@info cmd
run(cmd)
end
function generate(dir; execute=true, pluto=true)
quote
using Pkg
Pkg.activate(temp=true)
Pkg.add(name="Literate", rev="fe/pluto")
using Literate
const OUTDIR = $dir
const INFILE = joinpath(OUTDIR, "notebook.jl")
# generate pluto notebook:
if $pluto
TEMPDIR = tempdir()
Literate.notebook(INFILE, TEMPDIR, flavor=Literate.PlutoFlavor())
runcommand(`mv $TEMPDIR/notebook.jl $OUTDIR/notebook.pluto.jl`)
end
Literate.notebook(INFILE, OUTDIR, execute=false)
runcommand(
`mv $OUTDIR/notebook.ipynb $OUTDIR/notebook.unexecuted.ipynb`)
$execute && Literate.notebook(INFILE, OUTDIR, execute=true)
end |> eval
end
# Pkg.add("Pluto")
# using Pluto
# Pluto.run(notebook=joinpath(OUTDIR, "notebook.pluto.jl"))
# Pkg.add("IJulia")
# Pkg.instantiate()
# using IJulia
# IJulia.notebook(dir=OUTDIR)