Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make open_notebooks auto-generate the notebooks on demand #445

Merged
merged 2 commits into from
Oct 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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