Skip to content

Commit db379ca

Browse files
committed
Merge module maps and all docs links without overwriting existing entries, ensuring deduplication of links.
1 parent b552ba1 commit db379ca

File tree

1 file changed

+20
-2
lines changed
  • forc-plugins/forc-doc/src/render

1 file changed

+20
-2
lines changed

forc-plugins/forc-doc/src/render/mod.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,29 @@ impl RenderedDocumentation {
120120
for (rendered_doc, local_module_map, local_all_docs) in rendered_results? {
121121
rendered_docs.0.push(rendered_doc);
122122

123+
// Merge module maps without overwriting existing categories; append and dedup links.
123124
for (key, value) in local_module_map {
124-
module_map.entry(key).or_default().extend(value);
125+
let entry = module_map.entry(key).or_default();
126+
for (block, mut links) in value {
127+
let list = entry.entry(block).or_default();
128+
// Append new links while avoiding duplicates.
129+
for link in links.drain(..) {
130+
if !list.contains(&link) {
131+
list.push(link);
132+
}
133+
}
134+
}
125135
}
126136

127-
all_docs.links.extend(local_all_docs.links);
137+
// Merge "all docs" links similarly, preserving existing items.
138+
for (block, mut links) in local_all_docs.links {
139+
let list = all_docs.links.entry(block).or_default();
140+
for link in links.drain(..) {
141+
if !list.contains(&link) {
142+
list.push(link);
143+
}
144+
}
145+
}
128146
}
129147

130148
// ProjectIndex

0 commit comments

Comments
 (0)