Skip to content

Commit

Permalink
Test JuliaGPsDocs on repo (#124)
Browse files Browse the repository at this point in the history
* Adapt to use JuliaGPsDocs

* Update make.jl

* Update docs/make.jl

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: ST John <[email protected]>
  • Loading branch information
3 people authored Apr 2, 2022
1 parent b4f17c3 commit d8510de
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 133 deletions.
92 changes: 0 additions & 92 deletions docs/literate.jl

This file was deleted.

54 changes: 13 additions & 41 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,46 +1,15 @@
### Process examples
# Always rerun examples
const EXAMPLES_OUT = joinpath(@__DIR__, "src", "examples")
ispath(EXAMPLES_OUT) && rm(EXAMPLES_OUT; recursive=true)
mkpath(EXAMPLES_OUT)

# Install and precompile all packages
# Workaround for https://github.com/JuliaLang/Pkg.jl/issues/2219
examples = filter!(isdir, readdir(joinpath(@__DIR__, "..", "examples"); join=true))
let script = "using Pkg; Pkg.activate(ARGS[1]); Pkg.instantiate()"
for example in examples
if !success(`$(Base.julia_cmd()) -e $script $example`)
error(
"project environment of example ",
basename(example),
" could not be instantiated",
)
end
end
end
# Run examples asynchronously
processes = let literatejl = joinpath(@__DIR__, "literate.jl")
map(examples) do example
return run(
pipeline(
`$(Base.julia_cmd()) $literatejl $(basename(example)) $EXAMPLES_OUT`;
stdin=devnull,
stdout=devnull,
stderr=stderr,
);
wait=false,
)::Base.Process
end
end

# Check that all examples were run successfully
isempty(processes) || success(processes) || error("some examples were not run successfully")
using Pkg
Pkg.add(Pkg.PackageSpec(; url="https://github.com/JuliaGaussianProcesses/JuliaGPsDocs.jl")) # While the package is unregistered, it's a workaround

### Build documentation
using Documenter

using JuliaGPsDocs
using ApproximateGPs

JuliaGPsDocs.generate_examples(ApproximateGPs)

# Doctest setup
DocMeta.setdocmeta!(
ApproximateGPs,
Expand All @@ -58,11 +27,14 @@ makedocs(;
pages=[
"Home" => "index.md",
"userguide.md",
"API" => ["api/index.md", "api/sparsevariational.md", "api/laplace.md"],
"Examples" =>
map(filter!(filename -> endswith(filename, ".md"), readdir(EXAMPLES_OUT))) do x
return joinpath("examples", x)
end,
"API" => joinpath.(Ref("api"), ["index.md", "sparsevariational.md", "laplace.md"]),
"Examples" => map(
basename.(
filter!(isdir, readdir(joinpath(@__DIR__, "src", "examples"); join=true)),
),
) do x
joinpath("examples", x, "index.md")
end,
],
strict=true,
checkdocs=:exports,
Expand Down

0 comments on commit d8510de

Please sign in to comment.