forked from qojulia/QuantumOptics.jl-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake.jl
36 lines (28 loc) · 1.16 KB
/
make.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
sourcedir = "notebooks"
markdowndir = "markdown"
juliadir = "julia"
targetpath_examples = "../QuantumOptics.jl-documentation/src/examples"
if !isdir(markdowndir)
println("Creating markdown output directory at \"", markdowndir, "\"")
mkdir(markdowndir)
end
if !isdir(juliadir)
println("Creating julia source output directory at \"", juliadir, "\"")
mkdir(juliadir)
end
names = filter(name->endswith(name, ".ipynb"), readdir(sourcedir))
function convert2source(name)
sourcepath = joinpath(sourcedir, name)
run(`jupyter-nbconvert --to=script --ExecutePreprocessor.kernel_name=julia-0.6 --ExecutePreprocessor.timeout=100 --output-dir=$juliadir $sourcepath`)
end
function convert2markdown(name)
sourcepath = joinpath(sourcedir, name)
run(`jupyter-nbconvert --to markdown --ExecutePreprocessor.kernel_name=julia-0.6 --ExecutePreprocessor.timeout=100 --output-dir=$markdowndir --template=markdown_template.tpl --execute $sourcepath `)
end
for name in names
# Convert notebook to julia file
convert2source(name)
# Execute notebook and convert to rst
convert2markdown(name)
end
cp(markdowndir, targetpath_examples; remove_destination=true)