Skip to content

Commit b06a3da

Browse files
authored
fix(html): don't merge same-named symbols from different entrypoints in top symbols (#571)
1 parent d31407d commit b06a3da

File tree

1 file changed

+23
-29
lines changed

1 file changed

+23
-29
lines changed

src/html/util.rs

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -584,47 +584,41 @@ pub struct TopSymbolsCtx {
584584

585585
impl TopSymbolsCtx {
586586
pub fn new(ctx: &RenderContext) -> Option<Self> {
587-
let partitions = super::partition::partition_nodes_by_name(
588-
&ctx
589-
.ctx
590-
.doc_nodes
591-
.values()
592-
.flatten()
593-
.cloned()
594-
.collect::<Vec<_>>(),
595-
true,
596-
);
587+
let partitions = ctx
588+
.ctx
589+
.doc_nodes
590+
.values()
591+
.flat_map(|nodes| super::partition::partition_nodes_by_name(nodes, true))
592+
.collect::<Vec<_>>();
597593

598594
if partitions.is_empty() {
599595
return None;
600596
}
601597

598+
let total_symbols = partitions.len();
599+
602600
let symbols = partitions
603-
.values()
601+
.into_iter()
604602
.take(5)
605-
.map(|nodes| {
606-
let name = nodes[0].get_qualified_name();
607-
608-
TopSymbolCtx {
609-
kind: nodes
610-
.iter()
611-
.map(|node| node.kind_with_drilldown.into())
612-
.collect::<Vec<_>>(),
613-
href: ctx.ctx.href_resolver.resolve_path(
614-
ctx.get_current_resolve(),
615-
UrlResolveKind::Symbol {
616-
file: &nodes[0].origin,
617-
symbol: &name,
618-
},
619-
),
620-
name,
621-
}
603+
.map(|(name, nodes)| TopSymbolCtx {
604+
kind: nodes
605+
.iter()
606+
.map(|node| node.kind_with_drilldown.into())
607+
.collect::<Vec<_>>(),
608+
href: ctx.ctx.href_resolver.resolve_path(
609+
ctx.get_current_resolve(),
610+
UrlResolveKind::Symbol {
611+
file: &nodes[0].origin,
612+
symbol: &name,
613+
},
614+
),
615+
name,
622616
})
623617
.collect();
624618

625619
Some(Self {
626620
symbols,
627-
total_symbols: partitions.values().count(),
621+
total_symbols,
628622
all_symbols_href: ctx
629623
.ctx
630624
.href_resolver

0 commit comments

Comments
 (0)