Skip to content

Commit e20db94

Browse files
Rahban1mortenpi
andauthored
Remove at-meta, at-setup, at-docs from search index (#2675)
Co-authored-by: Morten Piibeleht <morten.piibeleht@gmail.com>
1 parent 4328aec commit e20db94

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
44
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
55

6+
## Unreleased
7+
8+
## Fixed
9+
10+
* `@meta`, `@setup`, and `@docs` blocks no longer generate spurious entries in the search index. ([#1929], [#2675])
11+
612
## Version [v1.10.1] - 2025-03-31
713

814
### Fixed

src/html/HTMLWriter.jl

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,20 @@ function SearchRecord(ctx, navnode, node::Node, ::MarkdownAST.AbstractElement)
713713
return SearchRecord(ctx, navnode; text = mdflatten(node))
714714
end
715715

716+
# Returns nothing for nodes that shouldn't be indexed in search
717+
const _SEARCHRECORD_IGNORED_BLOCK_TYPES = Union{
718+
Documenter.MetaNode,
719+
Documenter.DocsNodesBlock,
720+
Documenter.SetupNode,
721+
}
722+
function searchrecord(ctx::HTMLContext, navnode::Documenter.NavNode, node::Node)
723+
# Skip indexing special at-blocks
724+
if node.element isa _SEARCHRECORD_IGNORED_BLOCK_TYPES
725+
return nothing
726+
end
727+
return SearchRecord(ctx, navnode, node, node.element)
728+
end
729+
716730
function JSON.lower(rec::SearchRecord)
717731
# Replace any backslashes in links, if building the docs on Windows
718732
src = replace(rec.src, '\\' => '/')
@@ -1680,8 +1694,10 @@ end
16801694
function domify(dctx::DCtx)
16811695
ctx, navnode = dctx.ctx, dctx.navnode
16821696
return map(getpage(ctx, navnode).mdast.children) do node
1683-
rec = SearchRecord(ctx, navnode, node, node.element)
1684-
push!(ctx.search_index, rec)
1697+
rec = searchrecord(ctx, navnode, node)
1698+
if !isnothing(rec)
1699+
push!(ctx.search_index, rec)
1700+
end
16851701
domify(dctx, node, node.element)
16861702
end
16871703
end

0 commit comments

Comments
 (0)