Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix doctests and run them in CI #377

Merged
merged 1 commit into from
Dec 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Documenter
import Pkg
using Trixi
using Trixi2Vtk
using Trixi2Img

Expand All @@ -11,17 +12,8 @@ authors_text = read(joinpath(trixi_root_dir, "AUTHORS.md"), String)
authors_text = replace(authors_text, "in the [LICENSE.md](LICENSE.md) file" => "under [License](@ref)")
write(joinpath(@__DIR__, "src", "authors.md"), authors_text)

# Install dependencies and import modules...
# ...Trixi
Pkg.activate(trixi_root_dir)
Pkg.instantiate()
import Trixi

# Define module-wide setups such that the respective modules are available in doctests
DocMeta.setdocmeta!(Trixi,
:DocTestSetup,
:(push!(LOAD_PATH, ".."); using Trixi);
recursive=true)
DocMeta.setdocmeta!(Trixi, :DocTestSetup, :(using Trixi); recursive=true)
DocMeta.setdocmeta!(Trixi2Vtk, :DocTestSetup, :(using Trixi2Vtk); recursive=true)
DocMeta.setdocmeta!(Trixi2Img, :DocTestSetup, :(using Trixi2Img); recursive=true)

Expand Down
11 changes: 7 additions & 4 deletions src/auxiliary/special_elixirs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ providing examples with sensible default values for users.
# Examples

```jldoctest
julia> trixi_include(@__MODULE__, joinpath(examples_dir(), "1d", "elixir_advection_extended.jl"), tspan=(0.0, 0.1))
[...]

julia> sol.t[end]
julia> open(tempname(), "w") do io
redirect_stdout(io) do
trixi_include(@__MODULE__, joinpath(examples_dir(), "1d", "elixir_advection_extended.jl"),
tspan=(0.0, 0.1))
sol.t[end]
end
end
0.1
```
"""
Expand Down
2 changes: 2 additions & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[deps]
DiffEqCallbacks = "459566f4-90b8-5000-8ac3-15dfb0a30def"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Expand All @@ -8,5 +9,6 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
DiffEqCallbacks = "2.14"
Documenter = "0.26"
MPI = "0.15, 0.16"
OrdinaryDiffEq = "5.44"
4 changes: 4 additions & 0 deletions test/test_manual.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module TestManual

using Test
using Documenter
using Trixi

# Start with a clean environment: remove Trixi output directory if it exists
Expand Down Expand Up @@ -265,6 +266,9 @@ isdir(outdir) && rm(outdir, recursive=true)
@test_nowarn show(stdout, "text/plain", callback)
println()
end

DocMeta.setdocmeta!(Trixi, :DocTestSetup, :(using Trixi); recursive=true)
doctest(Trixi, manual=false)
end

end #module