Skip to content

Commit a7744d0

Browse files
committed
start docstring overhaul
1 parent 3d84dcb commit a7744d0

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ Manifest.toml
88
profile.pb.gz
99
.*.swp
1010
LocalPreferences.toml
11+
12+
docs/build

docs/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[deps]
22
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3+
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
34

45
[compat]
56
Documenter = "0.27"

src/OrdinaryDiffEq.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ import Preferences
124124
DEFAULT_PRECS(W, du, u, p, t, newW, Plprev, Prprev, solverdata) = nothing, nothing
125125

126126
include("misc_utils.jl")
127+
127128
include("algorithms.jl")
129+
include("algorithms/explicit_rk.jl")
130+
128131
include("alg_utils.jl")
129132

130133
include("nlsolve/type.jl")

src/algorithms/explicit_rk.jl

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
function explicit_rk_docstring(description::String)
2+
start_docstring = """
3+
```julia
4+
$FUNCTIONNAME(; stage_limiter! = OrdinaryDiffEq.trivial_limiter!,
5+
step_limiter! = OrdinaryDiffEq.trivial_limiter!,
6+
thread = OrdinaryDiffEq.False())
7+
```
8+
9+
Explicit Runge-Kutta Method.
10+
"""
11+
end_docstring = """
12+
13+
### Keyword Arguments
14+
15+
- `stage_limiter!`: function of the form `limiter!(u, integrator, p, t)`
16+
- `step_limiter!`: function of the form `limiter!(u, integrator, p, t)`
17+
- `thread`: determines whether internal broadcasting on
18+
appropriate CPU arrays should be serial (`thread = OrdinaryDiffEq.False()`,
19+
default) or use multiple threads (`thread = OrdinaryDiffEq.True()`) when
20+
Julia is started with multiple threads.
21+
"""
22+
start_docstring * description * end_docstring
23+
end
24+
25+
@doc explicit_rk_docstring("The second order Heun's method. Uses embedded Euler method for adaptivity.")
26+
struct Heun{StageLimiter, StepLimiter, Thread} <: OrdinaryDiffEqAdaptiveAlgorithm
27+
stage_limiter!::StageLimiter
28+
step_limiter!::StepLimiter
29+
thread::Thread
30+
end
31+
32+
function Heun(; stage_limiter! = trivial_limiter!, step_limiter! = trivial_limiter!,
33+
thread = False())
34+
Heun{typeof(stage_limiter!), typeof(step_limiter!), typeof(thread)}(stage_limiter!,
35+
step_limiter!,
36+
thread)
37+
end
38+
39+
# for backwards compatibility
40+
function Heun(stage_limiter!, step_limiter! = trivial_limiter!)
41+
Heun{typeof(stage_limiter!), typeof(step_limiter!), False}(stage_limiter!,
42+
step_limiter!,
43+
False())
44+
end
45+
46+
function Base.show(io::IO, alg::Heun)
47+
print(io, "Heun(stage_limiter! = ", alg.stage_limiter!,
48+
", step_limiter! = ", alg.step_limiter!,
49+
", thread = ", alg.thread, ")")
50+
end

0 commit comments

Comments
 (0)