Skip to content

Commit 93b9c60

Browse files
Merge pull request #550 from ChrisRackauckas/fix-formatting
Apply JuliaFormatter to fix code formatting
2 parents 325235e + 2f4d125 commit 93b9c60

File tree

8 files changed

+124
-119
lines changed

8 files changed

+124
-119
lines changed

.JuliaFormatter.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
style = "sciml"
2+
format_markdown = true
3+
format_docstrings = true

LICENSE.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@ The SciMLTutorials.jl package is licensed under the MIT "Expat" License:
1919
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
> SOFTWARE.
22-
>

docs/make.jl

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,29 @@ dir = @__DIR__() * "/.."
88
include("pages.jl")
99

1010
mathengine = MathJax3(Dict(:loader => Dict("load" => ["[tex]/require", "[tex]/mathtools"]),
11-
:tex => Dict("inlineMath" => [["\$", "\$"], ["\\(", "\\)"]],
12-
"packages" => [
13-
"base",
14-
"ams",
15-
"autoload",
16-
"mathtools",
17-
"require",
18-
])))
11+
:tex => Dict("inlineMath" => [["\$", "\$"], ["\\(", "\\)"]],
12+
"packages" => [
13+
"base",
14+
"ams",
15+
"autoload",
16+
"mathtools",
17+
"require"
18+
])))
1919

2020
makedocs(
21-
sitename="The SciML Tutorials",
22-
authors="Chris Rackauckas",
23-
modules=[SciMLTutorialsOutput],
24-
clean=true, doctest=false,
25-
format=Documenter.HTML(#analytics = "UA-90474609-3",
26-
assets=["assets/favicon.ico"],
27-
canonical="https://tutorials.sciml.ai/stable/",
21+
sitename = "The SciML Tutorials",
22+
authors = "Chris Rackauckas",
23+
modules = [SciMLTutorialsOutput],
24+
clean = true, doctest = false,
25+
format = Documenter.HTML(#analytics = "UA-90474609-3",
26+
assets = ["assets/favicon.ico"],
27+
canonical = "https://tutorials.sciml.ai/stable/",
2828
mathengine = mathengine),
29-
pages=pages
29+
pages = pages
3030
)
3131

3232
deploydocs(;
33-
repo="github.com/SciML/SciMLTutorialsOutput",
34-
devbranch="main",
35-
branch="main"
33+
repo = "github.com/SciML/SciMLTutorialsOutput",
34+
devbranch = "main",
35+
branch = "main"
3636
)

docs/pages.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@
22

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

5-
cp(joinpath(dir, "markdown"), joinpath(dir, "docs", "src"), force=true)
6-
cp(joinpath(dir, "docs", "extrasrc", "assets"), joinpath(dir, "docs", "src", "assets"), force=true)
7-
cp(joinpath(dir, "README.md"), joinpath(dir, "docs", "src", "index.md"), force=true)
5+
cp(joinpath(dir, "markdown"), joinpath(dir, "docs", "src"), force = true)
6+
cp(joinpath(dir, "docs", "extrasrc", "assets"), joinpath(dir, "docs", "src", "assets"), force = true)
7+
cp(joinpath(dir, "README.md"), joinpath(dir, "docs", "src", "index.md"), force = true)
88
tutorialsdir = joinpath(dir, "docs", "src")
99

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

1212
for folder in readdir(tutorialsdir)
1313
newpages = Any[]
14-
if folder[end-2:end] != ".md" && folder != "Testing" && folder != "figures" && folder != "assets"
15-
for file in filter(x -> x[end-2:end] == ".md", readdir(
14+
if folder[(end - 2):end] != ".md" && folder != "Testing" && folder != "figures" &&
15+
folder != "assets"
16+
for file in filter(x -> x[(end - 2):end] == ".md", readdir(
1617
joinpath(tutorialsdir, folder)))
1718
try
1819
filecontents = readlines(joinpath(tutorialsdir, folder, file))
19-
title = filecontents[3][9:end-1]
20+
title = filecontents[3][9:(end - 1)]
2021

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

4344
names = [
4445
"SciMLTutorials.jl: Tutorials for Scientific Machine Learning (SciML) and Equation Solvers"
45-
]
46+
]
4647

4748
for i in 1:length(pages)
4849
pages[i] = names[i] => pages[i][2]

docs/src/markdown/blank.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

src/SciMLTutorials.jl

Lines changed: 78 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -2,85 +2,87 @@ module SciMLTutorials
22

33
using Weave, Pkg, IJulia, InteractiveUtils, Markdown
44

5-
repo_directory = joinpath(@__DIR__,"..")
5+
repo_directory = joinpath(@__DIR__, "..")
66
cssfile = joinpath(@__DIR__, "..", "templates", "skeleton_css.css")
77
latexfile = joinpath(@__DIR__, "..", "templates", "julia_tex.tpl")
8-
default_builds = (:script,:github)
9-
10-
function weave_file(folder,file,build_list=default_builds)
11-
target = joinpath(folder, file)
12-
@info("Weaving $(target)")
13-
14-
if isfile(joinpath(folder, "Project.toml")) && build_list != (:notebook,)
15-
@info("Instantiating", folder)
16-
Pkg.activate(joinpath(folder))
17-
Pkg.instantiate()
18-
Pkg.build()
19-
20-
@info("Printing out `Pkg.status()`")
21-
Pkg.status()
22-
end
23-
24-
args = Dict{Symbol,String}(:folder=>folder,:file=>file)
25-
if :script build_list
26-
println("Building Script")
27-
dir = joinpath(repo_directory,"script",basename(folder))
28-
mkpath(dir)
29-
tangle(target; out_path=dir)
30-
end
31-
if :html build_list
32-
println("Building HTML")
33-
dir = joinpath(repo_directory,"html",basename(folder))
34-
mkpath(dir)
35-
weave(target,doctype = "md2html",out_path=dir,args=args,css=cssfile,fig_ext=".svg")
36-
end
37-
if :pdf build_list
38-
println("Building PDF")
39-
dir = joinpath(repo_directory,"pdf",basename(folder))
40-
mkpath(dir)
41-
try
42-
weave(target,doctype="md2pdf",out_path=dir,template=latexfile,args=args)
43-
catch ex
44-
@warn "PDF generation failed" exception=(ex, catch_backtrace())
8+
default_builds = (:script, :github)
9+
10+
function weave_file(folder, file, build_list = default_builds)
11+
target = joinpath(folder, file)
12+
@info("Weaving $(target)")
13+
14+
if isfile(joinpath(folder, "Project.toml")) && build_list != (:notebook,)
15+
@info("Instantiating", folder)
16+
Pkg.activate(joinpath(folder))
17+
Pkg.instantiate()
18+
Pkg.build()
19+
20+
@info("Printing out `Pkg.status()`")
21+
Pkg.status()
4522
end
46-
end
47-
if :github build_list
48-
println("Building Github Markdown")
49-
dir = joinpath(repo_directory,"markdown",basename(folder))
50-
mkpath(dir)
51-
weave(target,doctype = "github",out_path=dir,args=args)
52-
end
53-
if :notebook build_list
54-
println("Building Notebook")
55-
dir = joinpath(repo_directory,"notebook",basename(folder))
56-
mkpath(dir)
57-
Weave.convert_doc(target,joinpath(dir,file[1:end-4]*".ipynb"))
58-
end
59-
end
6023

61-
function weave_all(build_list=default_builds)
62-
for folder in readdir(joinpath(repo_directory,"tutorials"))
63-
folder == "test.jmd" && continue
64-
weave_folder(joinpath(repo_directory,"tutorials",folder),build_list)
65-
end
24+
args = Dict{Symbol, String}(:folder=>folder, :file=>file)
25+
if :script build_list
26+
println("Building Script")
27+
dir = joinpath(repo_directory, "script", basename(folder))
28+
mkpath(dir)
29+
tangle(target; out_path = dir)
30+
end
31+
if :html build_list
32+
println("Building HTML")
33+
dir = joinpath(repo_directory, "html", basename(folder))
34+
mkpath(dir)
35+
weave(target, doctype = "md2html", out_path = dir,
36+
args = args, css = cssfile, fig_ext = ".svg")
37+
end
38+
if :pdf build_list
39+
println("Building PDF")
40+
dir = joinpath(repo_directory, "pdf", basename(folder))
41+
mkpath(dir)
42+
try
43+
weave(target, doctype = "md2pdf", out_path = dir,
44+
template = latexfile, args = args)
45+
catch ex
46+
@warn "PDF generation failed" exception=(ex, catch_backtrace())
47+
end
48+
end
49+
if :github build_list
50+
println("Building Github Markdown")
51+
dir = joinpath(repo_directory, "markdown", basename(folder))
52+
mkpath(dir)
53+
weave(target, doctype = "github", out_path = dir, args = args)
54+
end
55+
if :notebook build_list
56+
println("Building Notebook")
57+
dir = joinpath(repo_directory, "notebook", basename(folder))
58+
mkpath(dir)
59+
Weave.convert_doc(target, joinpath(dir, file[1:(end - 4)]*".ipynb"))
60+
end
6661
end
6762

68-
function weave_folder(folder,build_list=default_builds)
69-
for file in readdir(joinpath(folder))
70-
# Skip non-`.jmd` files
71-
if !endswith(file, ".jmd")
72-
continue
63+
function weave_all(build_list = default_builds)
64+
for folder in readdir(joinpath(repo_directory, "tutorials"))
65+
folder == "test.jmd" && continue
66+
weave_folder(joinpath(repo_directory, "tutorials", folder), build_list)
7367
end
68+
end
7469

75-
try
76-
weave_file(folder,file,build_list)
77-
catch e
78-
@error(e)
70+
function weave_folder(folder, build_list = default_builds)
71+
for file in readdir(joinpath(folder))
72+
# Skip non-`.jmd` files
73+
if !endswith(file, ".jmd")
74+
continue
75+
end
76+
77+
try
78+
weave_file(folder, file, build_list)
79+
catch e
80+
@error(e)
81+
end
7982
end
80-
end
8183
end
8284

83-
function tutorial_footer(folder=nothing, file=nothing)
85+
function tutorial_footer(folder = nothing, file = nothing)
8486
display(md"""
8587
## Appendix
8688
@@ -109,8 +111,8 @@ function tutorial_footer(folder=nothing, file=nothing)
109111
Package Information:
110112
""")
111113

112-
proj = sprint(io -> Pkg.status(io=io))
113-
mani = sprint(io -> Pkg.status(io=io, mode = Pkg.PKGMODE_MANIFEST))
114+
proj = sprint(io -> Pkg.status(io = io))
115+
mani = sprint(io -> Pkg.status(io = io, mode = Pkg.PKGMODE_MANIFEST))
114116

115117
md = """
116118
```
@@ -127,12 +129,12 @@ function tutorial_footer(folder=nothing, file=nothing)
127129
end
128130

129131
function open_notebooks()
130-
Base.eval(Main, Meta.parse("import IJulia"))
131-
weave_all((:notebook,))
132-
path = joinpath(repo_directory,"notebook")
133-
newpath = joinpath(pwd(),"generated_notebooks")
134-
mv(path, newpath)
135-
IJulia.notebook(;dir=newpath)
132+
Base.eval(Main, Meta.parse("import IJulia"))
133+
weave_all((:notebook,))
134+
path = joinpath(repo_directory, "notebook")
135+
newpath = joinpath(pwd(), "generated_notebooks")
136+
mv(path, newpath)
137+
IJulia.notebook(; dir = newpath)
136138
end
137139

138140
end

test/runtests.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
using SciMLTutorials
2-
tutorials_dir = joinpath(dirname(@__DIR__), "tutorials")
3-
SciMLTutorials.weave_file(joinpath(tutorials_dir, "Testing"), "test.jmd")
1+
using SciMLTutorials
2+
tutorials_dir = joinpath(dirname(@__DIR__), "tutorials")
3+
SciMLTutorials.weave_file(joinpath(tutorials_dir, "Testing"), "test.jmd")

tutorials/Testing/test.jmd

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
---
2-
title: Test
3-
author: Chris Rackauckas
4-
---
5-
6-
This is a test of the builder system. It often gets bumped manually.
7-
8-
9-
```julia, echo = false, skip="notebook"
10-
using SciMLTutorials
11-
SciMLTutorials.tutorial_footer(WEAVE_ARGS[:folder],WEAVE_ARGS[:file])
12-
```
1+
---
2+
title: Test
3+
author: Chris Rackauckas
4+
---
5+
6+
This is a test of the builder system. It often gets bumped manually.
7+
8+
```julia, echo = false, skip="notebook"
9+
using SciMLTutorials
10+
SciMLTutorials.tutorial_footer(WEAVE_ARGS[:folder], WEAVE_ARGS[:file])
11+
```

0 commit comments

Comments
 (0)