func symbol_links(module: String, page: String, collection: &DocumentableCollection) -> [SymbolLink]Builds link targets for a module's standalone declaration pages.
Top-level declarations receive separate page URLs; nominal members share their owner's page and retain member anchors. Records can be combined across modules. Signature components such as parameter and type spellings are excluded because they have no independently rendered documentation.
View Source
pub func symbol_links(module: String, page: String, collection: &DocumentableCollection) -> [SymbolLink] {
let symbols: [SymbolLink] = []
for entry in collection.items {
let top_level = match entry.value {
.builtin(_) -> true,
.nominal(_) -> true,
.function(_) -> true,
.global(_) -> true,
.effect_declaration(_) -> true,
_ -> false
}
if top_level {
if let .some(name) = entry_name(entry: entry) {
let signature = signature_of(collection: collection, entry: entry)
let anchor = anchor_for(signature: signature.clone())
symbols.push(SymbolLink(
name: name.clone(),
qualified_name: name.clone(),
module: module.clone(),
page: symbol_page(module_page: page, signature: signature),
anchor: anchor,
owner: .none
))
}
}
if let .nominal(nominal) = entry.value {
let name = match nominal {
.#"struct"(name: name, generics: _, properties: _, methods: _) -> name.clone(),
.#"enum"(name: name, generics: _, variants: _, methods: _) -> name.clone(),
.#"protocol"(name: name, generics: _, properties: _, methods: _) -> name.clone()
}
let parent_signature = signature_of(collection: collection, entry: entry)
let parent_anchor = anchor_for(signature: parent_signature.clone())
let parent_page = symbol_page(module_page: page, signature: parent_signature)
match nominal {
.#"struct"(name: _, generics: _, properties: properties, methods: methods) -> {
for id in properties { append_symbol(collection: collection, module: module, page: parent_page, owner: name.clone(), parent_anchor: parent_anchor.clone(), id: id, symbols: symbols) }
for id in methods { append_symbol(collection: collection, module: module, page: parent_page, owner: name.clone(), parent_anchor: parent_anchor.clone(), id: id, symbols: symbols) }
},
.#"enum"(name: _, generics: _, variants: variants, methods: methods) -> {
for id in variants { append_symbol(collection: collection, module: module, page: parent_page, owner: name.clone(), parent_anchor: parent_anchor.clone(), id: id, symbols: symbols) }
for id in methods { append_symbol(collection: collection, module: module, page: parent_page, owner: name.clone(), parent_anchor: parent_anchor.clone(), id: id, symbols: symbols) }
},
.#"protocol"(name: _, generics: _, properties: properties, methods: methods) -> {
for id in properties { append_symbol(collection: collection, module: module, page: parent_page, owner: name.clone(), parent_anchor: parent_anchor.clone(), id: id, symbols: symbols) }
for id in methods { append_symbol(collection: collection, module: module, page: parent_page, owner: name.clone(), parent_anchor: parent_anchor.clone(), id: id, symbols: symbols) }
}
}
}
}
symbols
}