Skip to content

Commit d4833bf

Browse files
committed
add tests
1 parent 7d438cc commit d4833bf

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

src/MultiDocumenter.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,6 @@ function inject_styles_and_global_navigation(
270270
end
271271
continue
272272
end
273-
# no need to do anything about /index.html
274-
path == joinpath(dir, "index.html") && continue
275273

276274
endswith(file, ".html") || continue
277275

@@ -281,7 +279,11 @@ function inject_styles_and_global_navigation(
281279
stylesheets = make_global_stylesheet(custom_stylesheets, relpath(dir, root))
282280
scripts = make_global_scripts(custom_scripts, relpath(dir, root))
283281

282+
284283
page = read(path, String)
284+
if startswith(page, "<!--This file is automatically generated by Documenter.jl-->")
285+
continue
286+
end
285287
doc = Gumbo.parsehtml(page)
286288
injected = 0
287289

test/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
out
2+
clones

test/runtests.jl

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,48 @@ using MultiDocumenter
22
using Test
33

44
@testset "MultiDocumenter.jl" begin
5-
# Write your tests here.
5+
clonedir = mktempdir()
6+
7+
docs = [
8+
("JuliaDebug/Infiltrator.jl.git", "gh-pages") => MultiDocumenter.MultiDocRef(
9+
upstream = joinpath(clonedir, "Infiltrator"),
10+
path = "inf",
11+
name = "Infiltrator"
12+
),
13+
]
14+
15+
for ((remote, branch), docref) in docs
16+
run(`git clone --depth 1 [email protected]:$remote --branch $branch --single-branch $(docref.upstream)`)
17+
end
18+
19+
outpath = joinpath(@__DIR__, "out")
20+
21+
MultiDocumenter.make(
22+
outpath,
23+
collect(last.(docs));
24+
search_engine = MultiDocumenter.SearchConfig(
25+
index_versions = ["stable"],
26+
engine = MultiDocumenter.FlexSearch
27+
)
28+
)
29+
30+
@testset "flexsearch" begin
31+
@test isdir(outpath, "inf")
32+
@test isdir(outpath, "inf", "stable")
33+
@test isfile(outpath, "inf", "stable", "index.html")
34+
35+
@test read(joinpath(outpath, "inf", "index.html"), String) == """
36+
<!--This file is automatically generated by Documenter.jl-->
37+
<meta http-equiv="refresh" content="0; url=./stable/"/>
38+
"""
39+
40+
@test isdir(outpath, "search-data")
41+
store_content = read(joinpath(outpath, "search-data", "store.json"), String)
42+
@test !isempty(store_content)
43+
@test occursin("Infiltrator.jl", store_content)
44+
@test occursin("@infiltrate", store_content)
45+
end
46+
47+
rm(outpath, recursive=true, force=true)
48+
rm(clonedir, recursive=true, force=true)
649
end

0 commit comments

Comments
 (0)