-
Notifications
You must be signed in to change notification settings - Fork 37
/
make.jl
73 lines (57 loc) · 2.5 KB
/
make.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
67
68
69
70
71
72
73
using Documenter
using Literate
using Printf
using Tutorials
models_src = joinpath(@__DIR__,"..","models")
models_dst = joinpath(@__DIR__,"src","models")
assets_src = joinpath(@__DIR__,"..","assets")
assets_dst = joinpath(@__DIR__,"src","assets")
Sys.rm(models_dst;recursive=true,force=true)
Sys.rm(assets_dst;recursive=true,force=true)
Sys.cp(models_src,models_dst)
Sys.cp(assets_src,assets_dst)
pages_dir = joinpath(@__DIR__,"src","pages")
notebooks_dir = joinpath(@__DIR__,"src","notebooks")
Sys.rm(pages_dir;recursive=true,force=true)
Sys.rm(notebooks_dir;recursive=true,force=true)
repo_src = joinpath(@__DIR__,"..","src")
# Add index.md file as introduction to navigation menu
pages = ["Introduction"=> "index.md"]
binder_logo = "https://mybinder.org/badge_logo.svg"
nbviwer_logo = "https://img.shields.io/badge/show-nbviewer-579ACA.svg"
for (i,(title,filename)) in enumerate(Tutorials.files)
# Generate strings
tutorial_prefix = string("t",@sprintf "%03d_" i)
tutorial_title = string("# # Tutorial ", i, ": ", title)
tutorial_file = string(tutorial_prefix,splitext(filename)[1])
notebook_filename = string(tutorial_file, ".ipynb")
binder_url = joinpath("@__BINDER_ROOT_URL__","notebooks", notebook_filename)
nbviwer_url = joinpath("@__NBVIEWER_ROOT_URL__","notebooks", notebook_filename)
binder_badge = string("# [![](",binder_logo,")](",binder_url,")")
nbviwer_badge = string("# [![](",nbviwer_logo,")](",nbviwer_url,")")
# Generate notebooks
function preprocess_notebook(content)
return string(tutorial_title, "\n\n", content)
end
Literate.notebook(joinpath(repo_src,filename), notebooks_dir; name=tutorial_file, preprocess=preprocess_notebook, documenter=false, execute=false)
# Generate markdown
function preprocess_docs(content)
return string(tutorial_title, "\n", binder_badge, "\n", nbviwer_badge, "\n\n", content)
end
Literate.markdown(joinpath(repo_src,filename), pages_dir; name=tutorial_file, preprocess=preprocess_docs, codefence="```julia" => "```")
# Generate navigation menu entries
ordered_title = string(i, " ", title)
path_to_markdown_file = joinpath("pages",string(tutorial_file,".md"))
push!(pages, (ordered_title=>path_to_markdown_file))
end
makedocs(
sitename = "Gridap tutorials",
format = Documenter.HTML(),
pages = pages
)
# Documenter can also automatically deploy documentation to gh-pages.
# See "Hosting Documentation" and deploydocs() in the Documenter manual
# for more information.
deploydocs(
repo = "github.com/gridap/Tutorials.git"
)