-
Notifications
You must be signed in to change notification settings - Fork 39
/
build.jl
66 lines (61 loc) · 2.03 KB
/
build.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using Weave, Pkg, InteractiveUtils, IJulia
repo_directory = joinpath(@__DIR__)
cssfile = joinpath(@__DIR__, "templates", "skeleton_css.css")
latexfile = joinpath(@__DIR__, "templates", "julia_tex.tpl")
function weave_file(folder,file,build_list=(:script,:html,:github,:notebook); kwargs...)
tmp = joinpath(repo_directory,"tutorials",folder,file)
args = Dict{Symbol,String}(:folder=>folder,:file=>file)
if :script ∈ build_list
println("Building Script")
dir = joinpath(repo_directory,"script",folder)
isdir(dir) || mkdir(dir)
args[:doctype] = "script"
tangle(tmp;out_path=dir)
end
if :html ∈ build_list
println("Building HTML")
dir = joinpath(repo_directory,"html",folder)
isdir(dir) || mkdir(dir)
args[:doctype] = "html"
weave(tmp,doctype = "md2html",out_path=dir,args=args; fig_ext=".svg", css=cssfile, kwargs...)
end
if :pdf ∈ build_list
println("Building PDF")
dir = joinpath(repo_directory,"pdf",folder)
isdir(dir) || mkdir(dir)
args[:doctype] = "pdf"
weave(tmp,doctype="md2pdf",out_path=dir,args=args; template=latexfile, kwargs...)
end
if :github ∈ build_list
println("Building Github Markdown")
dir = joinpath(repo_directory,"markdown",folder)
isdir(dir) || mkdir(dir)
args[:doctype] = "github"
weave(tmp,doctype = "github",out_path=dir,args=args; kwargs...)
end
if :notebook ∈ build_list
println("Building Notebook")
dir = joinpath(repo_directory,"notebook",folder)
isdir(dir) || mkdir(dir)
args[:doctype] = "notebook"
Weave.convert_doc(tmp,joinpath(dir,file[1:end-4]*".ipynb"))
end
end
function weave_all()
for folder in readdir(joinpath(repo_directory,"tutorials"))
folder == "appendix.jl" && continue
weave_folder(folder)
end
end
function weave_folder(folder)
for file in readdir(joinpath(repo_directory,"tutorials",folder))
if file[findlast(isequal('.'),file):end]==".jmd"
println("Building $(joinpath(folder,file)))")
try
weave_file(folder,file)
catch
end
end
end
end
#weave_all()