Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
style = "sciml"
format_markdown = true
format_docstrings = true
1 change: 0 additions & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ The SciMLTutorials.jl package is licensed under the MIT "Expat" License:
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> SOFTWARE.
>
38 changes: 19 additions & 19 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@ dir = @__DIR__() * "/.."
include("pages.jl")

mathengine = MathJax3(Dict(:loader => Dict("load" => ["[tex]/require", "[tex]/mathtools"]),
:tex => Dict("inlineMath" => [["\$", "\$"], ["\\(", "\\)"]],
"packages" => [
"base",
"ams",
"autoload",
"mathtools",
"require",
])))
:tex => Dict("inlineMath" => [["\$", "\$"], ["\\(", "\\)"]],
"packages" => [
"base",
"ams",
"autoload",
"mathtools",
"require"
])))

makedocs(
sitename="The SciML Tutorials",
authors="Chris Rackauckas",
modules=[SciMLTutorialsOutput],
clean=true, doctest=false,
format=Documenter.HTML(#analytics = "UA-90474609-3",
assets=["assets/favicon.ico"],
canonical="https://tutorials.sciml.ai/stable/",
sitename = "The SciML Tutorials",
authors = "Chris Rackauckas",
modules = [SciMLTutorialsOutput],
clean = true, doctest = false,
format = Documenter.HTML(#analytics = "UA-90474609-3",
assets = ["assets/favicon.ico"],
canonical = "https://tutorials.sciml.ai/stable/",
mathengine = mathengine),
pages=pages
pages = pages
)

deploydocs(;
repo="github.com/SciML/SciMLTutorialsOutput",
devbranch="main",
branch="main"
repo = "github.com/SciML/SciMLTutorialsOutput",
devbranch = "main",
branch = "main"
)
17 changes: 9 additions & 8 deletions docs/pages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@

dir = @__DIR__() * "/.."

cp(joinpath(dir, "markdown"), joinpath(dir, "docs", "src"), force=true)
cp(joinpath(dir, "docs", "extrasrc", "assets"), joinpath(dir, "docs", "src", "assets"), force=true)
cp(joinpath(dir, "README.md"), joinpath(dir, "docs", "src", "index.md"), force=true)
cp(joinpath(dir, "markdown"), joinpath(dir, "docs", "src"), force = true)
cp(joinpath(dir, "docs", "extrasrc", "assets"), joinpath(dir, "docs", "src", "assets"), force = true)
cp(joinpath(dir, "README.md"), joinpath(dir, "docs", "src", "index.md"), force = true)
tutorialsdir = joinpath(dir, "docs", "src")

pages = Any["SciMLTutorials.jl: Tutorials for Scientific Machine Learning (SciML), Equation Solvers, and AI for Science"=>"index.md"]
pages = Any["SciMLTutorials.jl: Tutorials for Scientific Machine Learning (SciML), Equation Solvers, and AI for Science" => "index.md"]

for folder in readdir(tutorialsdir)
newpages = Any[]
if folder[end-2:end] != ".md" && folder != "Testing" && folder != "figures" && folder != "assets"
for file in filter(x -> x[end-2:end] == ".md", readdir(
if folder[(end - 2):end] != ".md" && folder != "Testing" && folder != "figures" &&
folder != "assets"
for file in filter(x -> x[(end - 2):end] == ".md", readdir(
joinpath(tutorialsdir, folder)))
try
filecontents = readlines(joinpath(tutorialsdir, folder, file))
title = filecontents[3][9:end-1]
title = filecontents[3][9:(end - 1)]

# Cut out the first 5 lines from the file to remove the Weave header stuff
open(joinpath(tutorialsdir, folder, file), "w") do output
Expand All @@ -42,7 +43,7 @@ permute!(pages,

names = [
"SciMLTutorials.jl: Tutorials for Scientific Machine Learning (SciML) and Equation Solvers"
]
]

for i in 1:length(pages)
pages[i] = names[i] => pages[i][2]
Expand Down
1 change: 1 addition & 0 deletions docs/src/markdown/blank.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

154 changes: 78 additions & 76 deletions src/SciMLTutorials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,85 +2,87 @@ module SciMLTutorials

using Weave, Pkg, IJulia, InteractiveUtils, Markdown

repo_directory = joinpath(@__DIR__,"..")
repo_directory = joinpath(@__DIR__, "..")
cssfile = joinpath(@__DIR__, "..", "templates", "skeleton_css.css")
latexfile = joinpath(@__DIR__, "..", "templates", "julia_tex.tpl")
default_builds = (:script,:github)

function weave_file(folder,file,build_list=default_builds)
target = joinpath(folder, file)
@info("Weaving $(target)")

if isfile(joinpath(folder, "Project.toml")) && build_list != (:notebook,)
@info("Instantiating", folder)
Pkg.activate(joinpath(folder))
Pkg.instantiate()
Pkg.build()

@info("Printing out `Pkg.status()`")
Pkg.status()
end

args = Dict{Symbol,String}(:folder=>folder,:file=>file)
if :script ∈ build_list
println("Building Script")
dir = joinpath(repo_directory,"script",basename(folder))
mkpath(dir)
tangle(target; out_path=dir)
end
if :html ∈ build_list
println("Building HTML")
dir = joinpath(repo_directory,"html",basename(folder))
mkpath(dir)
weave(target,doctype = "md2html",out_path=dir,args=args,css=cssfile,fig_ext=".svg")
end
if :pdf ∈ build_list
println("Building PDF")
dir = joinpath(repo_directory,"pdf",basename(folder))
mkpath(dir)
try
weave(target,doctype="md2pdf",out_path=dir,template=latexfile,args=args)
catch ex
@warn "PDF generation failed" exception=(ex, catch_backtrace())
default_builds = (:script, :github)

function weave_file(folder, file, build_list = default_builds)
target = joinpath(folder, file)
@info("Weaving $(target)")

if isfile(joinpath(folder, "Project.toml")) && build_list != (:notebook,)
@info("Instantiating", folder)
Pkg.activate(joinpath(folder))
Pkg.instantiate()
Pkg.build()

@info("Printing out `Pkg.status()`")
Pkg.status()
end
end
if :github ∈ build_list
println("Building Github Markdown")
dir = joinpath(repo_directory,"markdown",basename(folder))
mkpath(dir)
weave(target,doctype = "github",out_path=dir,args=args)
end
if :notebook ∈ build_list
println("Building Notebook")
dir = joinpath(repo_directory,"notebook",basename(folder))
mkpath(dir)
Weave.convert_doc(target,joinpath(dir,file[1:end-4]*".ipynb"))
end
end

function weave_all(build_list=default_builds)
for folder in readdir(joinpath(repo_directory,"tutorials"))
folder == "test.jmd" && continue
weave_folder(joinpath(repo_directory,"tutorials",folder),build_list)
end
args = Dict{Symbol, String}(:folder=>folder, :file=>file)
if :script ∈ build_list
println("Building Script")
dir = joinpath(repo_directory, "script", basename(folder))
mkpath(dir)
tangle(target; out_path = dir)
end
if :html ∈ build_list
println("Building HTML")
dir = joinpath(repo_directory, "html", basename(folder))
mkpath(dir)
weave(target, doctype = "md2html", out_path = dir,
args = args, css = cssfile, fig_ext = ".svg")
end
if :pdf ∈ build_list
println("Building PDF")
dir = joinpath(repo_directory, "pdf", basename(folder))
mkpath(dir)
try
weave(target, doctype = "md2pdf", out_path = dir,
template = latexfile, args = args)
catch ex
@warn "PDF generation failed" exception=(ex, catch_backtrace())
end
end
if :github ∈ build_list
println("Building Github Markdown")
dir = joinpath(repo_directory, "markdown", basename(folder))
mkpath(dir)
weave(target, doctype = "github", out_path = dir, args = args)
end
if :notebook ∈ build_list
println("Building Notebook")
dir = joinpath(repo_directory, "notebook", basename(folder))
mkpath(dir)
Weave.convert_doc(target, joinpath(dir, file[1:(end - 4)]*".ipynb"))
end
end

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

try
weave_file(folder,file,build_list)
catch e
@error(e)
function weave_folder(folder, build_list = default_builds)
for file in readdir(joinpath(folder))
# Skip non-`.jmd` files
if !endswith(file, ".jmd")
continue
end

try
weave_file(folder, file, build_list)
catch e
@error(e)
end
end
end
end

function tutorial_footer(folder=nothing, file=nothing)
function tutorial_footer(folder = nothing, file = nothing)
display(md"""
## Appendix

Expand Down Expand Up @@ -109,8 +111,8 @@ function tutorial_footer(folder=nothing, file=nothing)
Package Information:
""")

proj = sprint(io -> Pkg.status(io=io))
mani = sprint(io -> Pkg.status(io=io, mode = Pkg.PKGMODE_MANIFEST))
proj = sprint(io -> Pkg.status(io = io))
mani = sprint(io -> Pkg.status(io = io, mode = Pkg.PKGMODE_MANIFEST))

md = """
```
Expand All @@ -127,12 +129,12 @@ function tutorial_footer(folder=nothing, file=nothing)
end

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

end
6 changes: 3 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
using SciMLTutorials
tutorials_dir = joinpath(dirname(@__DIR__), "tutorials")
SciMLTutorials.weave_file(joinpath(tutorials_dir, "Testing"), "test.jmd")
using SciMLTutorials
tutorials_dir = joinpath(dirname(@__DIR__), "tutorials")
SciMLTutorials.weave_file(joinpath(tutorials_dir, "Testing"), "test.jmd")
23 changes: 11 additions & 12 deletions tutorials/Testing/test.jmd
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
---
title: Test
author: Chris Rackauckas
---

This is a test of the builder system. It often gets bumped manually.


```julia, echo = false, skip="notebook"
using SciMLTutorials
SciMLTutorials.tutorial_footer(WEAVE_ARGS[:folder],WEAVE_ARGS[:file])
```
---
title: Test
author: Chris Rackauckas
---

This is a test of the builder system. It often gets bumped manually.

```julia, echo = false, skip="notebook"
using SciMLTutorials
SciMLTutorials.tutorial_footer(WEAVE_ARGS[:folder], WEAVE_ARGS[:file])
```