@@ -4,16 +4,18 @@ import Gumbo, AbstractTrees
4
4
using HypertextLiteral
5
5
6
6
"""
7
- SearchConfig(index_versions = ["stable"], engine = MultiDocumenter.FlexSearch)
7
+ SearchConfig(index_versions = ["stable"], engine = MultiDocumenter.FlexSearch, lowfi = false )
8
8
9
9
`index_versions` is a vector of relative paths used for generating the search index. Only
10
10
the first matching path is considered.
11
11
`engine` may be `MultiDocumenter.FlexSearch`, `MultiDocumenter.Stork`, or a module that conforms
12
12
to the expected API (which is currently undocumented).
13
+ `lowfi = true` will try to minimize search index size. Only relevant for flexsearch.
13
14
"""
14
15
Base. @kwdef mutable struct SearchConfig
15
16
index_versions = [" stable" , " dev" ]
16
17
engine = FlexSearch
18
+ lowfi = false
17
19
end
18
20
19
21
struct MultiDocRef
@@ -280,7 +282,7 @@ function inject_styles_and_global_navigation(
280
282
end
281
283
pushfirst! (custom_stylesheets, joinpath (" assets" , " default" , " multidoc.css" ))
282
284
283
- for (root, _, files) in walkdir (dir)
285
+ @sync for (root, _, files) in walkdir (dir)
284
286
for file in files
285
287
path = joinpath (root, file)
286
288
if file == " documenter.js"
@@ -294,60 +296,61 @@ function inject_styles_and_global_navigation(
294
296
295
297
islink (path) && continue
296
298
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
-
302
299
page = read (path, String)
303
300
if startswith (
304
301
page,
305
302
" <!--This file is automatically generated by Documenter.jl-->" ,
306
303
)
307
304
continue
308
305
end
309
- doc = Gumbo. parsehtml (page)
310
- injected = 0
311
-
312
- for el in AbstractTrees. PreOrderDFS (doc. root)
313
- injected >= 2 && break
314
306
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
320
347
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
345
348
end
346
349
end
347
- end
348
350
349
- open (path, " w" ) do io
350
- print (io, doc)
351
+ open (path, " w" ) do io
352
+ print (io, doc)
353
+ end
351
354
end
352
355
end
353
356
end
0 commit comments