@@ -4,16 +4,18 @@ import Gumbo, AbstractTrees
44using HypertextLiteral
55
66"""
7- SearchConfig(index_versions = ["stable"], engine = MultiDocumenter.FlexSearch)
7+ SearchConfig(index_versions = ["stable"], engine = MultiDocumenter.FlexSearch, lowfi = false )
88
99`index_versions` is a vector of relative paths used for generating the search index. Only
1010the first matching path is considered.
1111`engine` may be `MultiDocumenter.FlexSearch`, `MultiDocumenter.Stork`, or a module that conforms
1212to the expected API (which is currently undocumented).
13+ `lowfi = true` will try to minimize search index size. Only relevant for flexsearch.
1314"""
1415Base. @kwdef mutable struct SearchConfig
1516 index_versions = [" stable" , " dev" ]
1617 engine = FlexSearch
18+ lowfi = false
1719end
1820
1921struct MultiDocRef
@@ -280,7 +282,7 @@ function inject_styles_and_global_navigation(
280282 end
281283 pushfirst! (custom_stylesheets, joinpath (" assets" , " default" , " multidoc.css" ))
282284
283- for (root, _, files) in walkdir (dir)
285+ @sync for (root, _, files) in walkdir (dir)
284286 for file in files
285287 path = joinpath (root, file)
286288 if file == " documenter.js"
@@ -294,60 +296,61 @@ function inject_styles_and_global_navigation(
294296
295297 islink (path) && continue
296298 isfile (path) || continue
297-
298- stylesheets = make_global_stylesheet (custom_stylesheets, relpath (dir, root))
299- scripts = make_global_scripts (custom_scripts, relpath (dir, root))
300-
301-
302299 page = read (path, String)
303300 if startswith (
304301 page,
305302 " <!--This file is automatically generated by Documenter.jl-->" ,
306303 )
307304 continue
308305 end
309- doc = Gumbo. parsehtml (page)
310- injected = 0
311-
312- for el in AbstractTrees. PreOrderDFS (doc. root)
313- injected >= 2 && break
314306
315- if el isa Gumbo. HTMLElement
316- if Gumbo. tag (el) == :head
317- for stylesheet in stylesheets
318- stylesheet. parent = el
319- push! (el. children, stylesheet)
307+ Threads. @spawn begin
308+ stylesheets = make_global_stylesheet (custom_stylesheets, relpath (dir, root))
309+ scripts = make_global_scripts (custom_scripts, relpath (dir, root))
310+
311+ doc = Gumbo. parsehtml (page)
312+ injected = 0
313+
314+ for el in AbstractTrees. PreOrderDFS (doc. root)
315+ injected >= 2 && break
316+
317+ if el isa Gumbo. HTMLElement
318+ if Gumbo. tag (el) == :head
319+ for stylesheet in stylesheets
320+ stylesheet. parent = el
321+ push! (el. children, stylesheet)
322+ end
323+ for script in scripts
324+ script. parent = el
325+ pushfirst! (el. children, script)
326+ end
327+ injected += 1
328+ elseif Gumbo. tag (el) == :body && ! isempty (el. children)
329+ documenter_div = first (el. children)
330+ if documenter_div isa Gumbo. HTMLElement &&
331+ Gumbo. getattr (documenter_div, " id" , " " ) == " documenter"
332+ @debug " Could not detect Documenter page layout in $path . This may be due to an old version of Documenter."
333+ end
334+ # inject global navigation as first element in body
335+
336+ global_nav = make_global_nav (
337+ dir,
338+ docs,
339+ root,
340+ brand_image,
341+ search_engine,
342+ prettyurls,
343+ )
344+ global_nav. parent = el
345+ pushfirst! (el. children, global_nav)
346+ injected += 1
320347 end
321- for script in scripts
322- script. parent = el
323- pushfirst! (el. children, script)
324- end
325- injected += 1
326- elseif Gumbo. tag (el) == :body && ! isempty (el. children)
327- documenter_div = first (el. children)
328- if documenter_div isa Gumbo. HTMLElement &&
329- Gumbo. getattr (documenter_div, " id" , " " ) == " documenter"
330- @debug " Could not detect Documenter page layout in $path . This may be due to an old version of Documenter."
331- end
332- # inject global navigation as first element in body
333-
334- global_nav = make_global_nav (
335- dir,
336- docs,
337- root,
338- brand_image,
339- search_engine,
340- prettyurls,
341- )
342- global_nav. parent = el
343- pushfirst! (el. children, global_nav)
344- injected += 1
345348 end
346349 end
347- end
348350
349- open (path, " w" ) do io
350- print (io, doc)
351+ open (path, " w" ) do io
352+ print (io, doc)
353+ end
351354 end
352355 end
353356 end
0 commit comments