From 2f4d125f05922d2f84375a631452a7f468dc2287 Mon Sep 17 00:00:00 2001 From: SciML Bot Date: Thu, 31 Jul 2025 17:26:21 -0400 Subject: [PATCH] Apply JuliaFormatter to fix code formatting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Applied JuliaFormatter with SciML style guide - Formatted 8 files 🤖 Generated by OrgMaintenanceScripts.jl --- .JuliaFormatter.toml | 3 + LICENSE.md | 1 - docs/make.jl | 38 ++++----- docs/pages.jl | 17 ++-- docs/src/markdown/blank.jl | 1 + src/SciMLTutorials.jl | 154 +++++++++++++++++++------------------ test/runtests.jl | 6 +- tutorials/Testing/test.jmd | 23 +++--- 8 files changed, 124 insertions(+), 119 deletions(-) create mode 100644 .JuliaFormatter.toml diff --git a/.JuliaFormatter.toml b/.JuliaFormatter.toml new file mode 100644 index 00000000..3494a9f1 --- /dev/null +++ b/.JuliaFormatter.toml @@ -0,0 +1,3 @@ +style = "sciml" +format_markdown = true +format_docstrings = true diff --git a/LICENSE.md b/LICENSE.md index 892203fa..6ec510bc 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -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. -> diff --git a/docs/make.jl b/docs/make.jl index 95a76021..19fec3c8 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -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" ) diff --git a/docs/pages.jl b/docs/pages.jl index 2f7a1176..e8f8df4e 100644 --- a/docs/pages.jl +++ b/docs/pages.jl @@ -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 @@ -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] diff --git a/docs/src/markdown/blank.jl b/docs/src/markdown/blank.jl index e69de29b..8b137891 100644 --- a/docs/src/markdown/blank.jl +++ b/docs/src/markdown/blank.jl @@ -0,0 +1 @@ + diff --git a/src/SciMLTutorials.jl b/src/SciMLTutorials.jl index c147388e..7841c3bf 100644 --- a/src/SciMLTutorials.jl +++ b/src/SciMLTutorials.jl @@ -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 @@ -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 = """ ``` @@ -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 diff --git a/test/runtests.jl b/test/runtests.jl index 9e6fddc8..8d7d6e65 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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") diff --git a/tutorials/Testing/test.jmd b/tutorials/Testing/test.jmd index 8c5a5ad4..4a909381 100644 --- a/tutorials/Testing/test.jmd +++ b/tutorials/Testing/test.jmd @@ -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]) +```