Skip to content

Commit

Permalink
Merge pull request #445 from SciML/notebooks
Browse files Browse the repository at this point in the history
Make open_notebooks auto-generate the notebooks on demand
  • Loading branch information
ChrisRackauckas authored Oct 3, 2021
2 parents 1306fb0 + 29a0d86 commit 02644f2
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/SciMLTutorials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ using Weave, Pkg, IJulia, InteractiveUtils, Markdown
repo_directory = joinpath(@__DIR__,"..")
cssfile = joinpath(@__DIR__, "..", "templates", "skeleton_css.css")
latexfile = joinpath(@__DIR__, "..", "templates", "julia_tex.tpl")
default_builds = (:script,:html,:github)

function weave_file(folder,file,build_list=(:script,:html,:pdf,:github,:notebook))
target = joinpath(folder, file)
function weave_file(folder,file,build_list=default_builds)
target = joinpath(repo_directory, "tutorials", folder, file)
@info("Weaving $(target)")

if isfile(joinpath(folder, "Project.toml"))
if isfile(joinpath(repo_directory, folder, "Project.toml"))
@info("Instantiating", folder)
Pkg.activate(folder)
Pkg.instantiate()
Expand Down Expand Up @@ -54,22 +55,22 @@ function weave_file(folder,file,build_list=(:script,:html,:pdf,:github,:notebook
end
end

function weave_all()
function weave_all(build_list=default_builds)
for folder in readdir(joinpath(repo_directory,"tutorials"))
folder == "test.jmd" && continue
weave_folder(folder)
weave_folder(folder,build_list)
end
end

function weave_folder(folder)
for file in readdir(folder)
function weave_folder(folder,build_list=default_builds)
for file in readdir(joinpath(repo_directory,"tutorials",folder))
# Skip non-`.jmd` files
if !endswith(file, ".jmd")
continue
end

try
weave_file(folder,file)
weave_file(folder,file,build_list)
catch e
@error(e)
end
Expand Down Expand Up @@ -124,6 +125,7 @@ end

function open_notebooks()
Base.eval(Main, Meta.parse("import IJulia"))
weave_all((:notebook,))
path = joinpath(repo_directory,"notebook")
IJulia.notebook(;dir=path)
end
Expand Down

0 comments on commit 02644f2

Please sign in to comment.