Skip to content

Commit

Permalink
Remove search.js as separate overridable asset (JuliaDocs#2236)
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenpi authored Aug 28, 2023
1 parent e2bd194 commit 2c08ddd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 19 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
File renamed without changes.
5 changes: 2 additions & 3 deletions docs/src/man/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ look like the following
build/
├── assets
│   ├── documenter.js
│   ├── search.js
│   ├── themes
│   │   ├── documenter-dark.css
│   │   └── documenter-light.css
Expand Down Expand Up @@ -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
Expand All @@ -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.
17 changes: 2 additions & 15 deletions src/html/HTMLWriter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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")],
Expand Down
1 change: 0 additions & 1 deletion test/examples/src/assets/search.js

This file was deleted.

0 comments on commit 2c08ddd

Please sign in to comment.