Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"

[compat]
Documenter = "1.1"
DocumenterCitations = "~1.3.4"
JSON = "0.21.4"
52 changes: 51 additions & 1 deletion docs/make_work.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
module BuildDoc

using Documenter, DocumenterCitations
using Documenter, DocumenterCitations, JSON

include("documenter_helpers.jl")
include("citation_style.jl")
Expand Down Expand Up @@ -210,6 +210,56 @@ function doit(
dstbase = normpath(Oscar.oscardir, "docs", "src", string(nameof(pkg)))
rm(dstbase; recursive=true, force=true)
end

# postprocessing, for the search index
docspath = normpath(joinpath(Oscar.oscardir, "docs"))
@info "Patching search index."
# extract valid json from search_index.js
run(pipeline(`sed -n '2p;3q' $(joinpath(docspath, "build", "search_index.js"))`, stdout=(joinpath(docspath, "build", "search_index.json")))) # imperfect file, but JSON parses it

# extract paths from doc.main
filelist=String[]
docmain = include(joinpath(docspath, "doc.main"))
while !isempty(docmain)
n = pop!(docmain)
if n isa Pair
push!(docmain, last(n))
elseif n isa String
push!(filelist, n)
elseif n isa Array{String}
append!(filelist,n)
elseif n isa Array
append!(docmain,n)
else
error("err: $(typeof(n))")
end
end
suffix = local_build ? ".html" : "/"
filelist = replace.(filelist, r"\.md$"=>suffix)

# read these files
iosearchindex = open(joinpath(docspath, "build", "search_index.json"), "r")
searchindex = JSON.parse(iosearchindex)
close(iosearchindex)

newsearchindex = []

for item in searchindex
if split(item["location"], "#")[1] in filelist
push!(newsearchindex, item)
end
end


# combine this to valid javascript again, and overwrite input
ionewsearchindex = open(joinpath(docspath, "build", "search_index.js"), "w")
write(ionewsearchindex, """var documenterSearchIndex = {"docs":\n""")
JSON.print(ionewsearchindex, newsearchindex)
write(ionewsearchindex, "\n}")
close(ionewsearchindex)

# clean up
rm(joinpath(docspath, "build", "search_index.json"))
end

end # module BuildDoc
Expand Down