Skip to content

Commit 54c47b7

Browse files
committed
setup documenter
1 parent 335c8ae commit 54c47b7

File tree

9 files changed

+178
-17
lines changed

9 files changed

+178
-17
lines changed

.github/workflows/Cleanup.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Doc Preview Cleanup
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
7+
# Ensure that only one "Doc Preview Cleanup" workflow is force pushing at a time
8+
concurrency:
9+
group: doc-preview-cleanup
10+
cancel-in-progress: false
11+
12+
jobs:
13+
doc-preview-cleanup:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
steps:
18+
- name: Checkout gh-pages branch
19+
uses: actions/checkout@v4
20+
with:
21+
ref: gh-pages
22+
- name: Delete preview and history + push changes
23+
run: |
24+
if [ -d "${preview_dir}" ]; then
25+
git config user.name "Documenter.jl"
26+
git config user.email "[email protected]"
27+
git rm -rf "${preview_dir}"
28+
git commit -m "delete preview"
29+
git branch gh-pages-new $(echo "delete history" | git commit-tree HEAD^{tree})
30+
git push --force origin gh-pages-new:gh-pages
31+
fi
32+
env:
33+
preview_dir: previews/PR${{ github.event.number }}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Documentation
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- main
7+
tags: "*"
8+
jobs:
9+
docs:
10+
name: Documentation
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: julia-actions/setup-julia@v1
15+
with:
16+
version: "1"
17+
- name: instantiate docs
18+
run: |
19+
julia --project=docs -e '
20+
using Pkg
21+
Pkg.develop(PackageSpec(path=pwd()))
22+
Pkg.instantiate()
23+
'
24+
- name: run doctests
25+
run: |
26+
julia --project=docs -e '
27+
using Documenter: DocMeta, doctest
28+
using NewtonKrylov
29+
DocMeta.setdocmeta!(NewtonKrylov, :DocTestSetup, :(using NewtonKrylov); recursive=true)
30+
doctest(NewtonKrylov)
31+
'
32+
- name: generate docs
33+
run: julia --project=docs docs/make.jl
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}

.github/workflows/TagBot.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: TagBot
2+
on:
3+
issue_comment:
4+
types:
5+
- created
6+
workflow_dispatch:
7+
jobs:
8+
TagBot:
9+
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: JuliaRegistries/TagBot@v1
13+
with:
14+
token: ${{ secrets.GITHUB_TOKEN }}
15+
ssh: ${{ secrets.DOCUMENTER_KEY }}

Project.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ version = "0.1.0"
66
[deps]
77
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
88
Krylov = "ba0b0d4f-ebba-5204-a429-3ac8c609bfb7"
9-
KrylovPreconditioners = "45d422c2-293f-44ce-8315-2cb988662dec"
109
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1110
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1211

docs/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Manifest.toml
2+
src/generated
3+
build

docs/Project.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[deps]
2+
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
3+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
4+
Krylov = "ba0b0d4f-ebba-5204-a429-3ac8c609bfb7"
5+
KrylovPreconditioners = "45d422c2-293f-44ce-8315-2cb988662dec"
6+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
7+
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
8+
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

docs/make.jl

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
pushfirst!(LOAD_PATH, joinpath(@__DIR__, "..")) # add NewtonKrylov to environment stack
2+
3+
using NewtonKrylov
4+
using Documenter
5+
import Documenter.Remotes: GitHub
6+
using Literate
7+
8+
DocMeta.setdocmeta!(NewtonKrylov, :DocTestSetup, :(using NewtonKrylov); recursive = true)
9+
10+
11+
##
12+
# Generate examples
13+
##
14+
15+
const EXAMPLES_DIR = joinpath(@__DIR__, "..", "examples")
16+
const OUTPUT_DIR = joinpath(@__DIR__, "src/generated")
17+
18+
examples = [
19+
"Bratu 1D" => "bratu",
20+
]
21+
22+
for (_, name) in examples
23+
example_filepath = joinpath(EXAMPLES_DIR, string(name, ".jl"))
24+
Literate.markdown(example_filepath, OUTPUT_DIR, documenter = true)
25+
end
26+
27+
examples = [title => joinpath("generated", string(name, ".md")) for (title, name) in examples]
28+
29+
makedocs(;
30+
modules = [NewtonKrylov],
31+
authors = "Valentin Churavy",
32+
repo = GitHub("vchuravy", "NewtonKrylov.jl"),
33+
sitename = "NewtonKrylov.jl",
34+
format = Documenter.HTML(;
35+
prettyurls = get(ENV, "CI", "false") == "true",
36+
canonical = "https://vchuravy.dev/NewtonKrylov.jl",
37+
assets = [
38+
asset(
39+
"https://plausible.io/js/plausible.js",
40+
class = :js,
41+
attributes = Dict(Symbol("data-domain") => "vchuravy.dev", :defer => "")
42+
),
43+
],
44+
mathengine = MathJax3(),
45+
),
46+
pages = [
47+
"Home" => "index.md",
48+
"Examples" => examples,
49+
],
50+
doctest = true,
51+
linkcheck = true,
52+
)
53+
54+
deploydocs(;
55+
repo = "github.com/vchuravy/NewtonKrylov.jl.git",
56+
devbranch = "main",
57+
push_preview = true,
58+
)

docs/src/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# NewtonKrylov.jl
2+
3+
## API
4+
5+
```@docs
6+
newton_krylov!
7+
NewtonKrylov.EisenstatWalker
8+
```

examples/bratu.jl

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
# 1D bratu equation
1+
# # 1D bratu equation
22

33
using NewtonKrylov, Krylov
44
using KrylovPreconditioners
55
using SparseArrays, LinearAlgebra
6+
using CairoMakie
67

78
function bratu!(res, y, Δx, λ)
89
N = length(y)
@@ -23,7 +24,7 @@ function bratu(y, dx, λ)
2324
end
2425

2526
function true_sol_bratu(x)
26-
# for λ = 3.51382, 2nd sol θ = 4.8057
27+
## for λ = 3.51382, 2nd sol θ = 4.8057
2728
θ = 4.79173
2829
return -2 * log(cosh* (x - 0.5) / 2) / (cosh/ 4)))
2930
end
@@ -52,34 +53,32 @@ uₖ_2 = newton_krylov(
5253
ϵ1 = abs2.(uₖ_1 .- reference)
5354
ϵ2 = abs2.(uₖ_1 .- reference)
5455

55-
##
56-
# Solving with a fixed forcing
56+
# ## Solving with a fixed forcing
5757
newton_krylov!(
5858
(res, u) -> bratu!(res, u, dx, λ),
5959
copy(u₀), similar(u₀);
6060
Solver = CgSolver,
6161
forcing = NewtonKrylov.Fixed()
6262
)
6363

64-
##
65-
# Solving with no forcing
64+
# ## Solving with no forcing
6665
newton_krylov!(
6766
(res, u) -> bratu!(res, u, dx, λ),
6867
copy(u₀), similar(u₀);
6968
Solver = CgSolver,
7069
forcing = nothing
7170
)
7271

73-
##
74-
# Solve using GMRES -- very slow
72+
# ## Solve using GMRES -- very slow
73+
# ```julia
7574
# @time newton_krylov!(
7675
# (res, u) -> bratu!(res, u, dx, λ),
7776
# copy(u₀), similar(u₀);
7877
# Solver = GmresSolver,
7978
# )
79+
# ```
8080

81-
##
82-
# Solve using GMRES + ILU Preconditoner
81+
# ## Solve using GMRES + ILU Preconditoner
8382
@time newton_krylov!(
8483
(res, u) -> bratu!(res, u, dx, λ),
8584
copy(u₀), similar(u₀);
@@ -88,8 +87,7 @@ newton_krylov!(
8887
ldiv = true,
8988
)
9089

91-
##
92-
# Solve using FGMRES + ILU Preconditoner
90+
# ## Solve using FGMRES + ILU Preconditoner
9391
@time newton_krylov!(
9492
(res, u) -> bratu!(res, u, dx, λ),
9593
copy(u₀), similar(u₀);
@@ -98,8 +96,7 @@ newton_krylov!(
9896
ldiv = true,
9997
)
10098

101-
##
102-
# Solve using FGMRES + GMRES Preconditoner
99+
# ## Solve using FGMRES + GMRES Preconditoner
103100
struct GmresPreconditioner{JOp}
104101
J::JOp
105102
itmax::Int
@@ -117,18 +114,22 @@ end
117114
N = (J) -> GmresPreconditioner(J, 30),
118115
)
119116

120-
# # Explodes..
117+
# ## Explodes..
118+
# ```julia
121119
# newton_krylov!(
122120
# (res, u) -> bratu!(res, u, dx, λ),
123121
# copy(u₀), similar(u₀);
124122
# verbose = 1,
125123
# Solver = CglsSolver, # CgneSolver
126124
# )
127-
125+
# ```
126+
#
127+
# ```julia
128128
# newton_krylov!(
129129
# (res, u) -> bratu!(res, u, dx, λ),
130130
# copy(u₀), similar(u₀);
131131
# verbose = 1,
132132
# Solver = BicgstabSolver,
133133
# η_max = nothing
134134
# )
135+
# ```

0 commit comments

Comments
 (0)