diff --git a/CHANGELOG.md b/CHANGELOG.md index c9e51a6f84..2457b0f9db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 **For upgrading:** If your builds are now failing due to the size threshold checks, you should first investigate why the generated HTML files are so large (e.g. you are likely automatically generating too much HTML, like extremely large inline SVG figures), and try to reduce them below the default thresholds. If you are unable to reduce the generated file size, you can increase the `size_threshold` value to just above the maximum size, or disable the enforcement of size threshold checks altogether by setting `size_threshold = nothing`. +* User-provided `assets/search.js` files no longer override Documenter's default search implementation, and the user-provided now gets ignored by default. ([#2236]) + + **For upgrading:** The JS file can still be include by passing it to the `assets` keyword of `format = HTML(...)`. However, it will likely conflict with Documenter's default search implementation. If you require an API to override Documenter's search engine, please open an issue. ### Added @@ -1642,6 +1645,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#2214]: https://github.com/JuliaDocs/Documenter.jl/issues/2214 [#2215]: https://github.com/JuliaDocs/Documenter.jl/issues/2215 [#2216]: https://github.com/JuliaDocs/Documenter.jl/issues/2216 +[#2236]: https://github.com/JuliaDocs/Documenter.jl/issues/2236 [JuliaLang/julia#36953]: https://github.com/JuliaLang/julia/issues/36953 [JuliaLang/julia#38054]: https://github.com/JuliaLang/julia/issues/38054 [JuliaLang/julia#39841]: https://github.com/JuliaLang/julia/issues/39841 diff --git a/assets/html/search.js b/assets/html/js/search.js similarity index 100% rename from assets/html/search.js rename to assets/html/js/search.js diff --git a/docs/src/man/guide.md b/docs/src/man/guide.md index 216d93a007..3b932cd604 100644 --- a/docs/src/man/guide.md +++ b/docs/src/man/guide.md @@ -122,7 +122,6 @@ look like the following build/ ├── assets │   ├── documenter.js -│   ├── search.js │   ├── themes │   │   ├── documenter-dark.css │   │   └── documenter-light.css @@ -378,7 +377,7 @@ During the build process, Documenter looks for suitable graphic images in the `src/assets/` directory and automatically copies them to `/build/assets/`. -You can use SVG, PNG, WEBP, GIF, or JPEG images. +You can use SVG, PNG, WEBP, GIF, or JPEG images. Documenter looks for files `logo.svg`, `logo.png`, `logo.webp`, `logo.gif`, `logo.jpg`, or `logo.jpeg`, in that @@ -391,7 +390,7 @@ called `logo-dark.svg` (or PNG/WEBP/GIF/JPEG). Files don't need to be square. Images with transparent backgrounds can look better, particularly for dark themes. -There's a `sidebar_sitename` keyword option for +There's a `sidebar_sitename` keyword option for [`Documenter.HTML`](@ref) that lets you hide the sitename that's usually displayed below a logo. This is useful if the logo already contains the name. diff --git a/src/html/HTMLWriter.jl b/src/html/HTMLWriter.jl index 323eecf1d1..4d8218330c 100644 --- a/src/html/HTMLWriter.jl +++ b/src/html/HTMLWriter.jl @@ -584,14 +584,13 @@ mutable struct HTMLContext documenter_js :: String themeswap_js :: String warner_js :: String - search_js :: String search_index :: Vector{SearchRecord} search_index_js :: String search_navnode :: Documenter.NavNode end HTMLContext(doc, settings=nothing) = HTMLContext( - doc, settings, [], "", "", "", "", [], "", + doc, settings, [], "", "", "", [], "", Documenter.NavNode("search", "Search", nothing), ) @@ -693,7 +692,7 @@ function render(doc::Documenter.Document, settings::HTML=HTML()) @warn "not creating 'documenter.js', provided by the user." else r = JSDependencies.RequireJS([ - RD.jquery, RD.jqueryui, RD.headroom, RD.headroom_jquery, + RD.jquery, RD.jqueryui, RD.headroom, RD.headroom_jquery, RD.minisearch, ]) RD.mathengine!(r, settings.mathengine) if !settings.prerender @@ -708,17 +707,6 @@ function render(doc::Documenter.Document, settings::HTML=HTML()) JSDependencies.writejs(joinpath(doc.user.build, "assets", "documenter.js"), r) end - # Generate search.js file with all the JS dependencies - ctx.search_js = "assets/search.js" - if isfile(joinpath(doc.user.source, "assets", "search.js")) - @warn "not creating 'search.js', provided by the user." - else - r = JSDependencies.RequireJS([RD.jquery, RD.minisearch]) - push!(r, JSDependencies.parse_snippet(joinpath(ASSETS, "search.js"))) - JSDependencies.verify(r; verbose=true) || error("RequireJS declaration is invalid") - JSDependencies.writejs(joinpath(doc.user.build, "assets", "search.js"), r) - end - for theme in THEMES copy_asset("themes/$(theme).css", doc) end @@ -918,7 +906,6 @@ function render_head(ctx, navnode) Symbol("data-main") => relhref(src, ctx.documenter_js) ], script[:src => relhref(src, ctx.search_index_js)], - script[:src => relhref(src, ctx.search_js)], script[:src => relhref(src, "siteinfo.js")], script[:src => relhref(src, "../versions.js")], diff --git a/test/examples/src/assets/search.js b/test/examples/src/assets/search.js deleted file mode 100644 index 4ef34f3d44..0000000000 --- a/test/examples/src/assets/search.js +++ /dev/null @@ -1 +0,0 @@ -// overrides Documenter's search.js