diff --git a/README.md b/README.md index b99cc35a..2964a832 100644 --- a/README.md +++ b/README.md @@ -30,24 +30,31 @@ Static outputs in pdf, markdown, and html reside in [SciMLTutorialsOutput](https ## Interactive Notebooks -To run the tutorials interactively via Jupyter notebooks and benchmark on your -own machine -1. Run Weave for the file (or folder) you are interested in -2. Activate the appropriate environment -3. Open and run the notebook. +To generate the interactive notebooks, first install the SciMLTutorials, instantiate the +environment, and then run `SciMLTutorials.open_notebooks()`. This looks as follows: -Note: Since notebooks default to looking for a Project.toml file at the same level or parent folder, you might need to move the notebook to the folder with the appropriate Project.toml. - -### Example (starting from the project root folder) ```julia -]activate . +]add SciMLTutorials#master +]activate SciMLTutorials ]instantiate using SciMLTutorials -SciMLTutorials.weave_file("tutorials/models", "01-classical_physics.jmd", [:notebook]) -]activate tutorials/models +SciMLTutorials.open_notebooks() +``` + +The tutorials will be generated at your `pwd()` in a folder called `generated_notebooks`. + +Note that when running the tutorials, the packages are not automatically added. Thus you +will need to add the packages manually or use the internal Project/Manifest tomls to +instantiate the correct packages. This can be done by activating the folder of the tutorials. +For example, + +```julia +using Pkg +Pkg.activate(joinpath(pkgdir(SciMLTutorials),"tutorials","models")) +Pkg.instantiate() ``` -Then move `01-classical_physics.jmd` to "tutorials/models" and open the notebook. +will add all of the packages required to run any tutorial in the `models` folder. ## Contributing diff --git a/src/SciMLTutorials.jl b/src/SciMLTutorials.jl index dd1e9c6d..c147388e 100644 --- a/src/SciMLTutorials.jl +++ b/src/SciMLTutorials.jl @@ -11,7 +11,7 @@ function weave_file(folder,file,build_list=default_builds) target = joinpath(folder, file) @info("Weaving $(target)") - if isfile(joinpath(folder, "Project.toml")) + if isfile(joinpath(folder, "Project.toml")) && build_list != (:notebook,) @info("Instantiating", folder) Pkg.activate(joinpath(folder)) Pkg.instantiate() @@ -61,7 +61,7 @@ end function weave_all(build_list=default_builds) for folder in readdir(joinpath(repo_directory,"tutorials")) folder == "test.jmd" && continue - weave_folder(folder,build_list) + weave_folder(joinpath(repo_directory,"tutorials",folder),build_list) end end @@ -130,7 +130,9 @@ function open_notebooks() Base.eval(Main, Meta.parse("import IJulia")) weave_all((:notebook,)) path = joinpath(repo_directory,"notebook") - IJulia.notebook(;dir=path) + newpath = joinpath(pwd(),"generated_notebooks") + mv(path, newpath) + IJulia.notebook(;dir=newpath) end end