-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update documentation build to documenter v1 (and fix it!) (#405)
* use JuliaDYnaics/doctheme updated * disable update message for now * add Cairomakie to doc deps * restore literate usage * add style files for reference * fix `Derived` usage and reference * remove documenter compat * fix the docbuild fail by not adding @pack in the docstrings
- Loading branch information
Showing
11 changed files
with
156 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
CI = get(ENV, "CI", nothing) == "true" || get(ENV, "GITHUB_TOKEN", nothing) !== nothing | ||
|
||
import Pkg | ||
Pkg.pkg"add Documenter@1" | ||
|
||
# Load documenter | ||
using Documenter | ||
using DocumenterTools: Themes | ||
ENV["JULIA_DEBUG"] = "Documenter" | ||
|
||
# For easier debugging when downloading from a specific branch. | ||
github_user = "JuliaDynamics" | ||
branch = "master" | ||
download_path = "https://raw.githubusercontent.com/$github_user/doctheme/$branch" | ||
|
||
import Downloads | ||
for file in ("juliadynamics-lightdefs.scss", "juliadynamics-darkdefs.scss", "juliadynamics-style.scss") | ||
Downloads.download("$download_path/$file", joinpath(@__DIR__, file)) | ||
end | ||
|
||
# create the themes | ||
for w in ("light", "dark") | ||
header = read(joinpath(@__DIR__, "juliadynamics-style.scss"), String) | ||
theme = read(joinpath(@__DIR__, "juliadynamics-$(w)defs.scss"), String) | ||
write(joinpath(@__DIR__, "juliadynamics-$(w).scss"), header*"\n"*theme) | ||
end | ||
|
||
# compile the themes | ||
Themes.compile(joinpath(@__DIR__, "juliadynamics-light.scss"), joinpath(@__DIR__, "src/assets/themes/documenter-light.css")) | ||
Themes.compile(joinpath(@__DIR__, "juliadynamics-dark.scss"), joinpath(@__DIR__, "src/assets/themes/documenter-dark.css")) | ||
|
||
# Download and apply CairoMakie plotting style | ||
using CairoMakie | ||
Downloads.download("$download_path/style.jl", joinpath(@__DIR__, "style.jl")) | ||
include("style.jl") | ||
|
||
function build_docs_with_style(pages, modules...; bib = nothing, authors = "George Datseris", draft = false, kwargs...) | ||
settings = ( | ||
modules = [modules...], | ||
format = Documenter.HTML( | ||
prettyurls = CI, | ||
assets = [ | ||
asset("https://fonts.googleapis.com/css?family=Montserrat|Source+Code+Pro&display=swap", class=:css), | ||
], | ||
collapselevel = 3, | ||
), | ||
sitename = "$(modules[1]).jl", | ||
authors, | ||
pages, | ||
draft, | ||
doctest = false, | ||
checkdocs = :exported, | ||
linkcheck_timeout = 2, | ||
# The following Documenter fails will NOT ERROR the docbuild! | ||
warnonly = [:doctest, :missing_docs], | ||
kwargs... | ||
) | ||
|
||
if isnothing(bib) | ||
makedocs(; settings...) | ||
else | ||
makedocs(; plugins=[bib], settings...) | ||
end | ||
|
||
if CI | ||
deploydocs( | ||
repo = "github.com/JuliaDynamics/$(modules[1]).jl.git", | ||
target = "build", | ||
push_preview = true | ||
) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,29 @@ | ||
cd(@__DIR__) | ||
using Pkg | ||
CI = get(ENV, "CI", nothing) == "true" || get(ENV, "GITHUB_TOKEN", nothing) !== nothing | ||
CI && Pkg.activate(@__DIR__) | ||
CI && Pkg.instantiate() | ||
using DrWatson | ||
using Documenter, DataFrames, Parameters, Dates, JLD2, UnPack | ||
using DocumenterTools: Themes | ||
using UnPack | ||
|
||
# %% | ||
# download the themes | ||
for file in ("juliadynamics-lightdefs.scss", "juliadynamics-darkdefs.scss", "juliadynamics-style.scss") | ||
download("https://raw.githubusercontent.com/JuliaDynamics/doctheme/master/$file", joinpath(@__DIR__, file)) | ||
end | ||
# create the themes | ||
for w in ("light", "dark") | ||
header = read(joinpath(@__DIR__, "juliadynamics-style.scss"), String) | ||
theme = read(joinpath(@__DIR__, "juliadynamics-$(w)defs.scss"), String) | ||
write(joinpath(@__DIR__, "juliadynamics-$(w).scss"), header*"\n"*theme) | ||
end | ||
# compile the themes | ||
Themes.compile(joinpath(@__DIR__, "juliadynamics-light.scss"), joinpath(@__DIR__, "src/assets/themes/documenter-light.css")) | ||
Themes.compile(joinpath(@__DIR__, "juliadynamics-dark.scss"), joinpath(@__DIR__, "src/assets/themes/documenter-dark.css")) | ||
# Convert workflow | ||
import Literate | ||
|
||
isdir(datadir()) && rm(datadir(); force = true, recursive = true) | ||
Literate.markdown(joinpath(@__DIR__, "src", "workflow.jl"), joinpath(@__DIR__, "src"); credit = false) | ||
|
||
using Literate | ||
Literate.markdown("src/workflow.jl", "src"; credit = false) | ||
pages = [ | ||
"Introduction" => "index.md", | ||
"DrWatson Workflow Tutorial" => "workflow.md", | ||
"Project Setup" => "project.md", | ||
"Naming Simulations" => "name.md", | ||
"Saving Tools" => "save.md", | ||
"Running & Listing Simulations" => "run&list.md", | ||
"Real World Examples" => "real_world.md" | ||
] | ||
|
||
makedocs(modules = [DrWatson, UnPack], | ||
sitename= "DrWatson", | ||
authors = "George Datseris and contributors.", | ||
doctest = false, | ||
format = Documenter.HTML( | ||
prettyurls = CI, | ||
assets = [ | ||
"assets/logo.ico", | ||
asset("https://fonts.googleapis.com/css?family=Quicksand|Montserrat|Source+Code+Pro|Lora&display=swap", class=:css), | ||
], | ||
), | ||
pages = [ | ||
"Introduction" => "index.md", | ||
"DrWatson Workflow Tutorial" => "workflow.md", | ||
"Project Setup" => "project.md", | ||
"Naming Simulations" => "name.md", | ||
"Saving Tools" => "save.md", | ||
"Running & Listing Simulations" => "run&list.md", | ||
"Real World Examples" => "real_world.md" | ||
], | ||
import Downloads | ||
Downloads.download( | ||
"https://raw.githubusercontent.com/JuliaDynamics/doctheme/master/build_docs_with_style.jl", | ||
joinpath(@__DIR__, "build_docs_with_style.jl") | ||
) | ||
include("build_docs_with_style.jl") | ||
|
||
if CI | ||
deploydocs( | ||
repo = "github.com/JuliaDynamics/DrWatson.jl.git", | ||
target = "build", | ||
push_preview = true | ||
) | ||
end | ||
build_docs_with_style(pages, DrWatson, UnPack; | ||
expandfirst = ["index.md"], warnonly = true, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Color theme definitions | ||
struct CyclicContainer <: AbstractVector{String} | ||
c::Vector{String} | ||
n::Int | ||
end | ||
CyclicContainer(c) = CyclicContainer(c, 0) | ||
|
||
Base.length(c::CyclicContainer) = length(c.c) | ||
Base.size(c::CyclicContainer) = size(c.c) | ||
Base.iterate(c::CyclicContainer, state=1) = iterate(c.c, state) | ||
Base.getindex(c::CyclicContainer, i) = c.c[(i-1)%length(c.c) + 1] | ||
Base.getindex(c::CyclicContainer, i::AbstractArray) = c.c[i] | ||
function Base.getindex(c::CyclicContainer) | ||
c.n += 1 | ||
c[c.n] | ||
end | ||
Base.iterate(c::CyclicContainer, i = 1) = iterate(c.c, i) | ||
|
||
COLORSCHEME = [ | ||
"#7143E0", | ||
"#0A9A84", | ||
"#191E44", | ||
"#AF9327", | ||
"#701B80", | ||
"#2E6137", | ||
] | ||
|
||
COLORS = CyclicContainer(COLORSCHEME) | ||
LINESTYLES = CyclicContainer(["-", ":", "--", "-."]) | ||
|
||
# other styling elements for Makie | ||
set_theme!(; | ||
palette = (color = COLORSCHEME,), | ||
fontsize = 22, | ||
figure_padding = 8, | ||
size = (800, 400), | ||
linewidth = 3.0, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters