@@ -25,6 +25,23 @@ Base.@kwdef mutable struct SearchConfig
25
25
lowfi = false
26
26
end
27
27
28
+ """
29
+ abstract type DropdownComponent
30
+
31
+ The supertype for any component that can be put in a dropdown column and
32
+ rendered using `MultiDocumenter.render(::YourComponent, thispagepath, dir, prettyurls)`.
33
+
34
+ All `DropdownComponent`s go in [`Column`](@ref)s, which go in [`MegaDropdownNav`](@ref).
35
+
36
+ Any subtype of `DropdownComponent` must implement that `render` method.
37
+
38
+ The main subtype is [`MultiDocRef`](@ref), which refers to external documentation
39
+ and adds it to the search index. However, there are others like [`ExternalLink`](@ref)
40
+ which is used to link to external sites without making them searchable, and
41
+ users can implement their own custom components.
42
+ """
43
+ abstract type DropdownComponent end
44
+
28
45
"""
29
46
struct MultiDocRef
30
47
@@ -44,7 +61,7 @@ Represents one set of docs that will get an entry in the MultiDocumenter navigat
44
61
* `fix_canonical_url`: this can be set to `false` to disable the canonical URL fixing
45
62
for this `MultiDocRef` (see also `canonical_domain` for [`make`](@ref)).
46
63
"""
47
- struct MultiDocRef
64
+ struct MultiDocRef <: DropdownComponent
48
65
upstream:: String
49
66
path:: String
50
67
name:: Any
66
83
67
84
struct DropdownNav
68
85
name:: String
69
- children:: Vector{MultiDocRef }
86
+ children:: Vector{DropdownComponent }
70
87
end
71
88
72
89
struct Column
73
90
name:: Any
74
- children:: Vector{MultiDocRef }
91
+ children:: Vector{DropdownComponent }
75
92
end
76
93
77
94
struct MegaDropdownNav
@@ -84,8 +101,8 @@ struct BrandImage
84
101
imagepath:: String
85
102
end
86
103
87
- function walk_outputs (f, root, docs:: Vector{MultiDocRef} , dirs:: Vector{String} )
88
- for ref in docs
104
+ function walk_outputs (f, root, docs:: Vector , dirs:: Vector{String} )
105
+ for ref in filter (x -> x isa MultiDocRef, docs)
89
106
p = joinpath (root, ref. path)
90
107
for dir in dirs
91
108
dirpath = joinpath (p, dir)
@@ -143,7 +160,7 @@ Aggregates multiple Documenter.jl-based documentation pages `docs` into `outdir`
143
160
"""
144
161
function make (
145
162
outdir,
146
- docs:: Vector ;
163
+ docs:: Vector{DropdownComponent} ;
147
164
assets_dir = nothing ,
148
165
brand_image:: Union{Nothing,BrandImage} = nothing ,
149
166
custom_stylesheets = [],
@@ -256,9 +273,9 @@ function make(
256
273
end
257
274
258
275
function flatten_multidocrefs (docs:: Vector )
259
- out = MultiDocRef []
276
+ out = []
260
277
for doc in docs
261
- if doc isa MultiDocRef
278
+ if doc isa DropdownComponent
262
279
push! (out, doc)
263
280
elseif doc isa MegaDropdownNav
264
281
for col in doc. columns
@@ -275,8 +292,8 @@ function flatten_multidocrefs(docs::Vector)
275
292
out
276
293
end
277
294
278
- function maybe_clone (docs:: Vector{MultiDocRef } )
279
- for doc in docs
295
+ function maybe_clone (docs:: Vector{<: DropdownComponent } )
296
+ for doc in filter (x -> x isa MultiDocRef, docs)
280
297
if ! isdir (doc. upstream)
281
298
if isempty (doc. giturl)
282
299
error (
@@ -314,14 +331,14 @@ function maybe_clone(docs::Vector{MultiDocRef})
314
331
end
315
332
316
333
function make_output_structure (
317
- docs:: Vector{MultiDocRef } ,
334
+ docs:: Vector{<: DropdownComponent } ,
318
335
prettyurls,
319
336
hide_previews;
320
337
canonical:: Union{AbstractString,Nothing} ,
321
338
)
322
339
dir = mktempdir ()
323
340
324
- for doc in docs
341
+ for doc in Iterators . filter (x -> x isa MultiDocRef, docs)
325
342
outpath = joinpath (dir, doc. path)
326
343
327
344
mkpath (dirname (outpath))
355
372
356
373
function make_global_nav (
357
374
dir,
358
- docs:: Vector ,
375
+ docs:: Vector{<: DropdownComponent} ,
359
376
thispagepath,
360
377
brand_image,
361
378
search_engine,
0 commit comments