Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
trixi-framework
GitHub Repository: trixi-framework/Trixi.jl
Path: blob/main/docs/make.jl
5582 views
1
using Documenter
2
import Pkg
3
using Changelog: Changelog
4
5
# Fix for https://github.com/trixi-framework/Trixi.jl/issues/668
6
if (get(ENV, "CI", nothing) != "true") &&
7
(get(ENV, "TRIXI_DOC_DEFAULT_ENVIRONMENT", nothing) != "true")
8
push!(LOAD_PATH, dirname(@__DIR__))
9
end
10
11
using Trixi
12
using Trixi2Vtk
13
using TrixiBase
14
15
# Get Trixi.jl root directory
16
trixi_root_dir = dirname(@__DIR__)
17
18
include(joinpath(trixi_root_dir, "docs", "literate", "make.jl"))
19
20
# Copy list of authors to not need to synchronize it manually
21
authors_text = read(joinpath(trixi_root_dir, "AUTHORS.md"), String)
22
authors_text = replace(authors_text,
23
"in the [LICENSE.md](LICENSE.md) file" => "under [License](@ref)")
24
write(joinpath(@__DIR__, "src", "authors.md"), authors_text)
25
26
# Define module-wide setups such that the respective modules are available in doctests
27
DocMeta.setdocmeta!(Trixi, :DocTestSetup, :(using Trixi); recursive = true)
28
DocMeta.setdocmeta!(Trixi2Vtk, :DocTestSetup, :(using Trixi2Vtk); recursive = true)
29
30
# Copy some files from the repository root directory to the docs and modify them
31
# as necessary
32
# Based on: https://github.com/ranocha/SummationByPartsOperators.jl/blob/0206a74140d5c6eb9921ca5021cb7bf2da1a306d/docs/make.jl#L27-L41
33
open(joinpath(@__DIR__, "src", "code_of_conduct.md"), "w") do io
34
# Point to source license file
35
println(io,
36
"""
37
```@meta
38
EditURL = "https://github.com/trixi-framework/Trixi.jl/blob/main/CODE_OF_CONDUCT.md"
39
```
40
""")
41
# Write the modified contents
42
println(io, "# [Code of Conduct](@id code-of-conduct)")
43
println(io, "")
44
for line in eachline(joinpath(dirname(@__DIR__), "CODE_OF_CONDUCT.md"))
45
line = replace(line, "[AUTHORS.md](AUTHORS.md)" => "[Authors](@ref)")
46
println(io, "> ", line)
47
end
48
end
49
50
open(joinpath(@__DIR__, "src", "contributing.md"), "w") do io
51
# Point to source license file
52
println(io,
53
"""
54
```@meta
55
EditURL = "https://github.com/trixi-framework/Trixi.jl/blob/main/CONTRIBUTING.md"
56
```
57
""")
58
# Write the modified contents
59
for line in eachline(joinpath(dirname(@__DIR__), "CONTRIBUTING.md"))
60
line = replace(line, "[LICENSE.md](LICENSE.md)" => "[License](@ref)")
61
line = replace(line, "[AUTHORS.md](AUTHORS.md)" => "[Authors](@ref)")
62
println(io, line)
63
end
64
end
65
66
# Create tutorials for the following files:
67
# Normal structure: "title" => "filename.jl"
68
# If there are several files for one topic and one folder, the structure is:
69
# "title" => ["subtitle 1" => ("folder 1", "filename 1.jl"),
70
# "subtitle 2" => ("folder 2", "filename 2.jl")]
71
files = [
72
# Topic: introduction
73
"First steps in Trixi.jl" => [
74
"Getting started" => ("first_steps", "getting_started.jl"),
75
"Create your first setup" => ("first_steps", "create_first_setup.jl"),
76
"Changing Trixi.jl itself" => ("first_steps", "changing_trixi.jl")
77
],
78
"Behind the scenes of a simulation setup" => "behind_the_scenes_simulation_setup.jl",
79
# Topic: DG semidiscretizations
80
"Introduction to DG methods" => "scalar_linear_advection_1d.jl",
81
"DGSEM with flux differencing" => "DGSEM_FluxDiff.jl",
82
"Shock capturing with flux differencing and stage limiter" => "shock_capturing.jl",
83
"Subcell limiting with the IDP Limiter" => "subcell_shock_capturing.jl",
84
"Non-periodic boundaries" => "non_periodic_boundaries.jl",
85
"DG schemes via `DGMulti` solver" => "DGMulti_1.jl",
86
"Other SBP schemes (FD, CGSEM) via `DGMulti` solver" => "DGMulti_2.jl",
87
"Upwind FD SBP schemes" => "upwind_fdsbp.jl",
88
# Topic: equations
89
"Adding a new scalar conservation law" => "adding_new_scalar_equations.jl",
90
"Adding a non-conservative equation" => "adding_nonconservative_equation.jl",
91
"Parabolic terms" => "parabolic_terms.jl",
92
"Adding new parabolic terms" => "adding_new_parabolic_terms.jl",
93
"Adding parabolic source terms" => "parabolic_source_terms.jl",
94
# Topic: meshes
95
"Adaptive mesh refinement" => "adaptive_mesh_refinement.jl",
96
"Structured mesh with curvilinear mapping" => "structured_mesh_mapping.jl",
97
"Unstructured meshes with HOHQMesh.jl" => "hohqmesh_tutorial.jl",
98
"P4est mesh from gmsh" => "p4est_from_gmsh.jl",
99
# Topic: other stuff
100
"Explicit time stepping" => "time_stepping.jl",
101
"Differentiable programming" => "differentiable_programming.jl",
102
"Custom semidiscretizations" => "custom_semidiscretization.jl"
103
]
104
tutorials = create_tutorials(files)
105
106
# Create changelog
107
Changelog.generate(Changelog.Documenter(), # output type
108
joinpath(@__DIR__, "..", "NEWS.md"), # input file
109
joinpath(@__DIR__, "src", "changelog_tmp.md"); # output file
110
repo = "trixi-framework/Trixi.jl", # default repository for links
111
branch = "main",)
112
# Fix edit URL of changelog
113
open(joinpath(@__DIR__, "src", "changelog.md"), "w") do io
114
for line in eachline(joinpath(@__DIR__, "src", "changelog_tmp.md"))
115
if startswith(line, "EditURL")
116
line = "EditURL = \"https://github.com/trixi-framework/Trixi.jl/blob/main/NEWS.md\""
117
end
118
println(io, line)
119
end
120
end
121
# Remove temporary file
122
rm(joinpath(@__DIR__, "src", "changelog_tmp.md"))
123
124
# Make documentation
125
makedocs(
126
# Specify modules for which docstrings should be shown
127
modules = [Trixi, TrixiBase, Trixi2Vtk],
128
# Set sitename to Trixi.jl
129
sitename = "Trixi.jl",
130
# Provide additional formatting options
131
format = Documenter.HTML(
132
# Disable pretty URLs during manual testing
133
prettyurls = get(ENV, "CI", nothing) == "true",
134
# Explicitly add favicon as asset
135
assets = ["assets/favicon.ico"],
136
# Set canonical URL to GitHub pages URL
137
canonical = "https://trixi-framework.github.io/TrixiDocumentation/stable",
138
size_threshold_ignore = ["reference-trixi.md"]),
139
# Explicitly specify documentation structure
140
pages = [
141
"Home" => "index.md",
142
"Getting started" => [
143
"Overview" => "overview.md",
144
"Visualization" => "visualization.md",
145
"Restart simulation" => "restart.md"
146
],
147
"Tutorials" => tutorials,
148
"Basic building blocks" => [
149
"Meshes" => [
150
"Tree mesh" => joinpath("meshes", "tree_mesh.md"),
151
"Structured mesh" => joinpath("meshes", "structured_mesh.md"),
152
"Unstructured mesh" => joinpath("meshes", "unstructured_quad_mesh.md"),
153
"P4est-based mesh" => joinpath("meshes", "p4est_mesh.md"),
154
"DGMulti mesh" => joinpath("meshes", "dgmulti_mesh.md")
155
],
156
"Time integration" => "time_integration.md",
157
"Callbacks" => "callbacks.md",
158
"Coupling" => "multi-physics_coupling.md"
159
],
160
"Advanced topics & developers" => [
161
"Conventions" => "conventions.md",
162
"Development" => "development.md",
163
"GitHub & Git" => "github-git.md",
164
"Style guide" => "styleguide.md",
165
"Testing" => "testing.md",
166
"Performance" => "performance.md",
167
"Parallelization" => "parallelization.md",
168
"Heterogeneous" => "heterogeneous.md"
169
],
170
"Troubleshooting and FAQ" => "troubleshooting.md",
171
"Reference" => [
172
"Trixi.jl" => "reference-trixi.md",
173
"TrixiBase.jl" => "reference-trixibase.md",
174
"Trixi2Vtk.jl" => "reference-trixi2vtk.md"
175
],
176
"Changelog" => "changelog.md",
177
"Authors" => "authors.md",
178
"Contributing" => "contributing.md",
179
"Code of Conduct" => "code_of_conduct.md",
180
"License" => "license.md"
181
])
182
183
deploydocs(repo = "github.com/trixi-framework/Trixi.jl",
184
deploy_repo = "github.com/trixi-framework/TrixiDocumentation",
185
devbranch = "main",
186
# Only push previews if all the relevant environment variables are non-empty.
187
push_preview = all(!isempty,
188
(get(ENV, "GITHUB_TOKEN", ""),
189
get(ENV, "DOCUMENTER_KEY", ""))))
190
191