|
1 | | -using Documenter |
2 | | - |
3 | | -using Downloads: download |
4 | | -using Documenter.Writers: HTMLWriter |
5 | | -using DocumenterTools.Themes |
6 | | - |
7 | | - |
8 | | -# download and compile theme |
9 | | -assetsdir(args...) = joinpath(@__DIR__, "src", "assets", args...) |
10 | | -site = "https://github.com/JuliaTeachingCTU/JuliaCTUGraphics/raw/main/" |
11 | | -force = true |
12 | | - |
13 | | -mkpath(assetsdir("themes")) |
14 | | -mv(download("$(site)logo/CTU-logo-dark.svg"), assetsdir("logo-dark.svg"); force) |
15 | | -mv(download("$(site)logo/CTU-logo.svg"), assetsdir("logo.svg"); force) |
16 | | -mv(download("$(site)icons/favicon.ico"), assetsdir("favicon.ico"); force) |
17 | | - |
18 | | -# for theme in ["light", "dark"] |
19 | | -# mktemp(@__DIR__) do path, io |
20 | | -# write(io, join([ |
21 | | -# read(joinpath(HTMLWriter.ASSETS_THEMES, "documenter-$(theme).css"), String), |
22 | | -# read(download("$(site)assets/lectures-$(theme).css"), String) |
23 | | -# ], "\n")) |
24 | | -# Themes.compile( |
25 | | -# path, |
26 | | -# joinpath(@__DIR__, assetsdir("themes", "documenter-$(theme).css")) |
27 | | -# ) |
28 | | -# end |
29 | | -# end |
30 | | - |
31 | | - |
32 | | -# documentation |
| 1 | +using Documenter, DocumenterVitepress |
| 2 | +using Documenter.Remotes |
| 3 | + |
| 4 | +using Scientific_Programming_in_Julia |
| 5 | + |
| 6 | +# This is needed for live preview |
| 7 | +if get(ENV, "VITREPRESS_LIVE_PREVIEW", "false") == "true" |
| 8 | + VITREPRESS_KWARGS = (; |
| 9 | + md_output_path=".", |
| 10 | + build_vitepress=false, |
| 11 | + ) |
| 12 | + MAKEDOCS_KWARGS = (; clean=false,) |
| 13 | +else |
| 14 | + VITREPRESS_KWARGS = (;) |
| 15 | + MAKEDOCS_KWARGS = (;) |
| 16 | +end |
| 17 | + |
| 18 | +@show VITREPRESS_KWARGS |
| 19 | +@show MAKEDOCS_KWARGS |
| 20 | + |
| 21 | +# utilities |
| 22 | +function add_prefix(prefix::S, pair::Pair{S,T}) where {S<:AbstractString,T} |
| 23 | + key, val = pair |
| 24 | + if isa(val, AbstractString) |
| 25 | + return key => joinpath(prefix, val) |
| 26 | + else |
| 27 | + return key => add_prefix(prefix, val) |
| 28 | + end |
| 29 | +end |
| 30 | + |
| 31 | +function add_prefix(prefix::AbstractString, pairs::AbstractVector{<:Pair}) |
| 32 | + return add_prefix.(prefix, pairs) |
| 33 | +end |
| 34 | + |
| 35 | +# pages |
33 | 36 | pages = [ |
34 | 37 | "Home" => "index.md", |
35 | | - "Installation" => "installation.md", |
36 | | - "Projects" => "projects.md", |
37 | | - "1: Introduction" => [ |
38 | | - "Motivation" => "./lecture_01/motivation.md", |
39 | | - "Basics" => "./lecture_01/basics.md", |
40 | | - "Examples" => "./lecture_01/demo.md", |
41 | | - "Outline" => "./lecture_01/outline.md", |
42 | | - "Lab" => "./lecture_01/lab.md", |
43 | | - "Homework" => "./lecture_01/hw.md", |
44 | | - ], |
45 | | - |
46 | | - "2: The power of type system & multiple dispatch" => [ |
47 | | - "Lecture" => "./lecture_02/lecture.md", |
48 | | - "Lab" => "./lecture_02/lab.md", |
49 | | - "Homework" => "./lecture_02/hw.md", |
50 | | - ], |
51 | | - |
52 | | - "3: Design patterns" => [ |
53 | | - "Lecture" => "./lecture_03/lecture.md", |
54 | | - "Lab" => "./lecture_03/lab.md", |
55 | | - "Homework" => "./lecture_03/hw.md", |
56 | | - ], |
57 | | - |
58 | | - "4: Package development, unit tests & CI" => [ |
59 | | - "Lecture" => "./lecture_04/lecture.md", |
60 | | - "Lab" => "./lecture_04/lab.md", |
61 | | - "Homework" => "./lecture_04/hw.md", |
62 | | - ], |
63 | | - |
64 | | - "5: Performance benchmarking" => [ |
65 | | - "Lecture" => "./lecture_05/lecture.md", |
66 | | - "Lab" => "./lecture_05/lab.md", |
67 | | - "Homework" => "./lecture_05/hw.md", |
68 | | - ], |
69 | | - |
70 | | - "6: Lanuage introspection" => [ |
71 | | - "Lecture" => "./lecture_06/lecture.md", |
72 | | - "Lab" => "./lecture_06/lab.md", |
73 | | - "Homework" => "./lecture_06/hw.md", |
74 | | - ], |
75 | | - |
76 | | - "7: Macros" => [ |
77 | | - "Lecture" => "./lecture_07/lecture.md", |
78 | | - "Lab" => "./lecture_07/lab.md", |
79 | | - "Homework" => "./lecture_07/hw.md", |
80 | | - ], |
81 | | - |
82 | | - "8: Automatic differentiation" => [ |
83 | | - "Lecture" => "./lecture_08/lecture.md", |
84 | | - "Lab" => "./lecture_08/lab.md", |
85 | | - "Homework" => "./lecture_08/hw.md", |
86 | | - ], |
87 | | - |
88 | | - "9: Intermediate representation" => [ |
89 | | - "Lecture v.2 (newest)" => "./lecture_09/lecture.md", |
90 | | - "Lecture v.1 (older)" => "./lecture_09_v1/lecture.md", |
91 | | - "Lab" => "./lecture_09_v1/lab.md", |
92 | | - ], |
93 | | - |
94 | | - "10: Parallel programming" => [ |
95 | | - "Lecture" => "./lecture_10/lecture.md", |
96 | | - "Lab" => "./lecture_10/lab.md", |
97 | | - "Homework" => "./lecture_10/hw.md", |
98 | | - ], |
99 | | - |
100 | | - "11: GPU programming" => [ |
101 | | - "Lecture" => "./lecture_11/lecture.md", |
102 | | - "Lab" => "./lecture_11/lab.md", |
103 | | - ], |
104 | | - |
105 | | - "12: Ordinary Differential Equations" => [ |
106 | | - "Lecture" => "./lecture_12/lecture.md", |
107 | | - "Lab" => "./lecture_12/lab.md", |
108 | | - "Homework" => "./lecture_12/hw.md", |
109 | | - ], |
| 38 | + "Tutorials" => add_prefix("./tutorials", [ |
| 39 | + "Installation" => "installation.md", |
| 40 | + ]), |
| 41 | + "Projects" => add_prefix("./projects", [ |
| 42 | + "Requirements" => "requirements.md", |
| 43 | + "Potential projects" => "projects.md", |
| 44 | + ]), |
| 45 | + "Lectures" => add_prefix("./lectures", [ |
| 46 | + "Outline" => "outline.md", |
| 47 | + "1: Introduction" => add_prefix("lecture_01", [ |
| 48 | + "Motivation" => "motivation.md", |
| 49 | + "Basics" => "basics.md", |
| 50 | + "Examples" => "demo.md", |
| 51 | + "Lab" => "lab.md", |
| 52 | + "Homework" => "hw.md", |
| 53 | + ]), |
| 54 | + ]), |
110 | 55 | ] |
111 | 56 |
|
| 57 | +# documentation |
| 58 | +organisation = "JuliaTeachingCTU" |
| 59 | +repository = "Scientific-Programming-in-Julia" |
| 60 | +repo = Remotes.GitHub(organisation, repository) |
112 | 61 |
|
113 | 62 | makedocs(; |
114 | | - authors = "JuliaTeachingCTU", |
115 | | - # repo = "https://github.com/JuliaTeachingCTU/Scientific-Programming-in-Julia/blob/{commit}{path}#{line}", |
116 | | - sitename = "Scientific Programming in Julia", |
117 | | - pagesonly = true, |
118 | | - format = Documenter.HTML(; |
119 | | - prettyurls = true, |
120 | | - canonical = "https://JuliaTeachingCTU.github.io/Scientific-Programming-in-Julia", |
121 | | - assets = ["assets/favicon.ico"], |
122 | | - collapselevel = 1, |
123 | | - ansicolor=true, |
124 | | - mathengine=Documenter.MathJax3(), |
| 63 | + modules=[Scientific_Programming_in_Julia], |
| 64 | + authors=organisation, |
| 65 | + repo=repo, |
| 66 | + sitename="Scientific Programming in Julia", |
| 67 | + format=DocumenterVitepress.MarkdownVitepress(; |
| 68 | + repo=Remotes.repourl(repo), |
| 69 | + VITREPRESS_KWARGS..., |
125 | 70 | ), |
126 | | - pages |
| 71 | + pages=pages, |
| 72 | + warnonly=true, |
| 73 | + MAKEDOCS_KWARGS..., |
127 | 74 | ) |
| 75 | + |
128 | 76 | deploydocs(; |
129 | | - repo = "github.com/JuliaTeachingCTU/Scientific-Programming-in-Julia", |
| 77 | + repo=repo, |
| 78 | + target="build", |
| 79 | + devbranch="main", |
| 80 | + branch="gh-pages", |
| 81 | + push_preview=true, |
130 | 82 | ) |
0 commit comments