@@ -501,6 +501,7 @@ struct HTML <: Documenter.Writer
501501 size_threshold_warn:: Int
502502 size_threshold_ignore:: Vector{String}
503503 example_size_threshold:: Int
504+ search_size_threshold_warn:: Int
504505 inventory_version:: Union{String, Nothing}
505506
506507 function HTML (;
@@ -530,6 +531,7 @@ struct HTML <: Documenter.Writer
530531 # seems reasonable, and that would lead to ~80 KiB, which is still fine
531532 # and leaves a buffer before hitting `size_threshold_warn`.
532533 example_size_threshold:: Union{Integer, Nothing} = 8 * 2 ^ 10 , # 8 KiB
534+ search_size_threshold_warn:: Union{Integer, Nothing} = 500 * 2 ^ 10 , # 500 KiB
533535 inventory_version = nothing ,
534536
535537 # deprecated keywords
@@ -581,6 +583,11 @@ struct HTML <: Documenter.Writer
581583 elseif example_size_threshold < 0
582584 throw (ArgumentError (" example_size_threshold must be non-negative, got $(example_size_threshold) " ))
583585 end
586+ if isnothing (search_size_threshold_warn)
587+ search_size_threshold_warn = typemax (Int)
588+ elseif search_size_threshold_warn <= 0
589+ throw (ArgumentError (" search_size_threshold_warn must be non-negative, got $(search_size_threshold_warn) " ))
590+ end
584591 isa (edit_link, Default) && (edit_link = edit_link[])
585592 # We use normpath() when we construct the .page value for NavNodes, so we also need to normpath()
586593 # these values. This also ensures cross-platform compatibility of the values.
@@ -590,6 +597,7 @@ struct HTML <: Documenter.Writer
590597 collapselevel, sidebar_sitename, highlights, mathengine, description, footer,
591598 ansicolor, lang, warn_outdated, prerender, node, highlightjs,
592599 size_threshold, size_threshold_warn, size_threshold_ignore, example_size_threshold,
600+ search_size_threshold_warn,
593601 (isnothing (inventory_version) ? nothing : string (inventory_version))
594602 )
595603 end
@@ -861,11 +869,25 @@ function render(doc::Documenter.Document, settings::HTML = HTML())
861869 # Check that all HTML files are smaller or equal to size_threshold option
862870 all (size_limit_successes) || throw (HTMLSizeThresholdError ())
863871
864- open (joinpath (doc. user. build, ctx. search_index_js), " w" ) do io
872+ # Check the size of the search index
873+ search_index_path = joinpath (doc. user. build, ctx. search_index_js)
874+ open (search_index_path, " w" ) do io
865875 println (io, " var documenterSearchIndex = {\" docs\" :" )
866876 # convert Vector{SearchRecord} to a JSON string + do additional JS escaping
867877 println (io, JSDependencies. json_jsescape (ctx. search_index), " \n }" )
868878 end
879+ let file_size = filesize (search_index_path)
880+ if file_size > settings. search_size_threshold_warn
881+ file_size_format_results = format_units (file_size)
882+ size_threshold_warn_format_results = format_units (settings. search_size_threshold_warn)
883+ @warn """
884+ Generated search index over size_threshold_warn limit:
885+ Generated file size: $(file_size_format_results)
886+ search_size_threshold_warn: $(size_threshold_warn_format_results)
887+ Search index file: $(search_index_path)
888+ """
889+ end
890+ end
869891
870892 write_inventory (doc, ctx)
871893
0 commit comments