Skip to content

Commit

Permalink
Merge pull request #53 from JuliaComputing/sp/disable-previews
Browse files Browse the repository at this point in the history
feat: add `hide_previews` arg
  • Loading branch information
pfitzseb authored Apr 11, 2023
2 parents 0eeb757 + 7dddedc commit 6322685
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/MultiDocumenter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ const DEFAULT_ENGINE = SearchConfig(index_versions = ["stable", "dev"], engine =
custom_scripts = [],
search_engine = SearchConfig(),
prettyurls = true,
rootpath = "/"
rootpath = "/",
hide_previews = true,
)
Aggregates multiple Documenter.jl-based documentation pages `docs` into `outdir`.
Expand All @@ -102,7 +103,8 @@ Aggregates multiple Documenter.jl-based documentation pages `docs` into `outdir`
`Docs.HTML` objects are inserted as the content of inline scripts.
- `search_engine` inserts a global search bar if not `false`. See [`SearchConfig`](@ref) for more details.
- `prettyurls` removes all `index.html` suffixes from links in the global navigation.
-`rootpath` is the path your site ends up being deployed at, e.g. `/foo/` if it's hosted at `https://bar.com/foo`
- `rootpath` is the path your site ends up being deployed at, e.g. `/foo/` if it's hosted at `https://bar.com/foo`
- `hide_previews` removes preview builds from the aggregated documentation.
"""
function make(
outdir,
Expand All @@ -114,10 +116,11 @@ function make(
search_engine = DEFAULT_ENGINE,
prettyurls = true,
rootpath = "/",
hide_previews = true,
)
maybe_clone(flatten_multidocrefs(docs))

dir = make_output_structure(flatten_multidocrefs(docs), prettyurls)
dir = make_output_structure(flatten_multidocrefs(docs), prettyurls, hide_previews)
out_assets = joinpath(dir, "assets")
if assets_dir !== nothing && isdir(assets_dir)
cp(assets_dir, out_assets)
Expand Down Expand Up @@ -189,7 +192,7 @@ function maybe_clone(docs::Vector{MultiDocRef})
end
end

function make_output_structure(docs::Vector{MultiDocRef}, prettyurls)
function make_output_structure(docs::Vector{MultiDocRef}, prettyurls, hide_previews)
dir = mktempdir()

for doc in docs
Expand All @@ -202,6 +205,11 @@ function make_output_structure(docs::Vector{MultiDocRef}, prettyurls)
if isdir(gitpath)
rm(gitpath, recursive = true)
end

previewpath = joinpath(outpath, "previews")
if hide_previews && isdir(previewpath)
rm(previewpath, recursive = true)
end
end

open(joinpath(dir, "index.html"), "w") do io
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ using Test

@testset "structure" begin
@test isdir(outpath, "inf")
@test !isdir(outpath, "inf", "previews")
@test isdir(outpath, "inf", "stable")
@test isfile(outpath, "inf", "stable", "index.html")

Expand Down

0 comments on commit 6322685

Please sign in to comment.