Skip to content

Commit

Permalink
Improve build script
Browse files Browse the repository at this point in the history
  • Loading branch information
moyner committed Sep 27, 2024
1 parent c2b9a65 commit 181a45b
Showing 1 changed file with 33 additions and 26 deletions.
59 changes: 33 additions & 26 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using DocumenterCitations
using DocumenterVitepress
##
cd(@__DIR__)
function build_jutul_darcy_docs(build_format = nothing; build_examples = true, build_validation_examples = build_examples, build_notebooks = build_examples, clean = true)
function build_jutul_darcy_docs(build_format = nothing; build_examples = true, build_validation_examples = build_examples, build_notebooks = true, clean = true)
DocMeta.setdocmeta!(JutulDarcy, :DocTestSetup, :(using JutulDarcy; using Jutul); recursive=true)
DocMeta.setdocmeta!(Jutul, :DocTestSetup, :(using Jutul); recursive=true)
bib = CitationBibliography(joinpath(@__DIR__, "src", "refs.bib"))
Expand Down Expand Up @@ -45,7 +45,7 @@ function build_jutul_darcy_docs(build_format = nothing; build_examples = true, b
return content*"\n\n # ## Example on GitHub\n "*
"# If you would like to run this example yourself, it can be downloaded from "*
"the JutulDarcy.jl GitHub repository [as a script](https://github.com/sintefmath/JutulDarcy.jl/blob/main/examples/$pth.jl), "*
"or as a [Notebook](https://github.com/sintefmath/JutulDarcy.jl/blob/gh-pages/dev/$pth.ipynb)"
"or as a [Jupyter Notebook](https://github.com/sintefmath/JutulDarcy.jl/blob/gh-pages/dev/final_site/notebooks/$pth.ipynb)"
end
if clean
for (ex, pth) in examples
Expand Down Expand Up @@ -82,25 +82,20 @@ function build_jutul_darcy_docs(build_format = nothing; build_examples = true, b
upd(content) = update_footer(content, pth)
Literate.markdown(in_pth, out_dir, preprocess = upd)
end
if build_notebooks
Literate.notebook(in_pth, notebook_dir, execute = false)
end
end
## Docs
if isnothing(build_format)
if false
build_format = Documenter.HTML(;
prettyurls=get(ENV, "CI", "false") == "true",
canonical="https://sintefmath.github.io/JutulDarcy.jl",
edit_link="main",
size_threshold_ignore = ["ref/jutul.md", "docstrings.md"],
assets=String["assets/citations.css"],
)
else
build_format = DocumenterVitepress.MarkdownVitepress(
repo = "https://github.com/sintefmath/JutulDarcy.jl",
)
end
# Old Documenter code in case we want to go back.
# build_format = Documenter.HTML(;
# prettyurls=get(ENV, "CI", "false") == "true",
# canonical="https://sintefmath.github.io/JutulDarcy.jl",
# edit_link="main",
# size_threshold_ignore = ["ref/jutul.md", "docstrings.md"],
# assets=String["assets/citations.css"],
# )
build_format = DocumenterVitepress.MarkdownVitepress(
repo = "https://github.com/sintefmath/JutulDarcy.jl",
)
end
makedocs(;
modules=[JutulDarcy, Jutul],
Expand Down Expand Up @@ -128,6 +123,7 @@ function build_jutul_darcy_docs(build_format = nothing; build_examples = true, b
"man/basics/secondary.md",
"man/basics/parameters.md",
"man/basics/plotting.md",
"man/basics/utilities.md",
],
"Further reading" => [
"man/advanced/mpi.md",
Expand All @@ -140,14 +136,25 @@ function build_jutul_darcy_docs(build_format = nothing; build_examples = true, b
"Examples: Validation" => validation_markdown
],
)

deploydocs(;
repo="github.com/sintefmath/JutulDarcy.jl.git",
devbranch="main",
target = "build", # this is where Vitepress stores its output
branch = "gh-pages",
push_preview = true
)
if build_notebooks
# Subfolder of final site build folder
notebook_dir = joinpath(@__DIR__, "build", "final_site", "notebooks")
mkpath(notebook_dir)
for (ex, pth) in examples
in_pth = example_path(pth)
@info "$ex Writing notebook to $notebook_dir"
Literate.notebook(in_pth, notebook_dir, execute = false)
end
end
if deploy
deploydocs(;
repo="github.com/sintefmath/JutulDarcy.jl.git",
devbranch="main",
target = "build", # this is where Vitepress stores its output
branch = "gh-pages",
push_preview = true
)
end
end
##
# build_jutul_darcy_docs(build_examples = false, build_validation_examples = false)
Expand Down

0 comments on commit 181a45b

Please sign in to comment.