Skip to content

Commit 02644f2

Browse files
Merge pull request #445 from SciML/notebooks
Make open_notebooks auto-generate the notebooks on demand
2 parents 1306fb0 + 29a0d86 commit 02644f2

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/SciMLTutorials.jl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ using Weave, Pkg, IJulia, InteractiveUtils, Markdown
55
repo_directory = joinpath(@__DIR__,"..")
66
cssfile = joinpath(@__DIR__, "..", "templates", "skeleton_css.css")
77
latexfile = joinpath(@__DIR__, "..", "templates", "julia_tex.tpl")
8+
default_builds = (:script,:html,:github)
89

9-
function weave_file(folder,file,build_list=(:script,:html,:pdf,:github,:notebook))
10-
target = joinpath(folder, file)
10+
function weave_file(folder,file,build_list=default_builds)
11+
target = joinpath(repo_directory, "tutorials", folder, file)
1112
@info("Weaving $(target)")
1213

13-
if isfile(joinpath(folder, "Project.toml"))
14+
if isfile(joinpath(repo_directory, folder, "Project.toml"))
1415
@info("Instantiating", folder)
1516
Pkg.activate(folder)
1617
Pkg.instantiate()
@@ -54,22 +55,22 @@ function weave_file(folder,file,build_list=(:script,:html,:pdf,:github,:notebook
5455
end
5556
end
5657

57-
function weave_all()
58+
function weave_all(build_list=default_builds)
5859
for folder in readdir(joinpath(repo_directory,"tutorials"))
5960
folder == "test.jmd" && continue
60-
weave_folder(folder)
61+
weave_folder(folder,build_list)
6162
end
6263
end
6364

64-
function weave_folder(folder)
65-
for file in readdir(folder)
65+
function weave_folder(folder,build_list=default_builds)
66+
for file in readdir(joinpath(repo_directory,"tutorials",folder))
6667
# Skip non-`.jmd` files
6768
if !endswith(file, ".jmd")
6869
continue
6970
end
7071

7172
try
72-
weave_file(folder,file)
73+
weave_file(folder,file,build_list)
7374
catch e
7475
@error(e)
7576
end
@@ -124,6 +125,7 @@ end
124125

125126
function open_notebooks()
126127
Base.eval(Main, Meta.parse("import IJulia"))
128+
weave_all((:notebook,))
127129
path = joinpath(repo_directory,"notebook")
128130
IJulia.notebook(;dir=path)
129131
end

0 commit comments

Comments
 (0)