@@ -2,85 +2,87 @@ module SciMLTutorials
2
2
3
3
using Weave, Pkg, IJulia, InteractiveUtils, Markdown
4
4
5
- repo_directory = joinpath (@__DIR__ ," .." )
5
+ repo_directory = joinpath (@__DIR__ , " .." )
6
6
cssfile = joinpath (@__DIR__ , " .." , " templates" , " skeleton_css.css" )
7
7
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 ()
45
22
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
60
23
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
66
61
end
67
62
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)
73
67
end
68
+ end
74
69
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
79
82
end
80
- end
81
83
end
82
84
83
- function tutorial_footer (folder= nothing , file= nothing )
85
+ function tutorial_footer (folder = nothing , file = nothing )
84
86
display (md """
85
87
## Appendix
86
88
@@ -109,8 +111,8 @@ function tutorial_footer(folder=nothing, file=nothing)
109
111
Package Information:
110
112
""" )
111
113
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))
114
116
115
117
md = """
116
118
```
@@ -127,12 +129,12 @@ function tutorial_footer(folder=nothing, file=nothing)
127
129
end
128
130
129
131
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)
136
138
end
137
139
138
140
end
0 commit comments