MCPcopy Index your code
hub / github.com/endbasic/endbasic / callables_to_index

Function callables_to_index

std/src/help.rs:142–161  ·  view source on GitHub ↗

Generates the index for a collection of `CallableMetadata`s to use in a `CategoryTopic`.

(metadatas: &[Rc<CallableMetadata>])

Source from the content-addressed store, hash-verified

140
141/// Generates the index for a collection of `CallableMetadata`s to use in a `CategoryTopic`.
142fn callables_to_index(metadatas: &[Rc<CallableMetadata>]) -> BTreeMap<String, &'static str> {
143 let category = metadatas.first().expect("Must have at least one symbol").category();
144
145 let mut index = BTreeMap::default();
146 for metadata in metadatas {
147 debug_assert_eq!(
148 category,
149 metadata.category(),
150 "All commands registered in this category must be equivalent"
151 );
152 let name = match metadata.return_type() {
153 None => metadata.name().to_owned(),
154 Some(return_type) => format!("{}{}", metadata.name(), return_type.annotation()),
155 };
156 let blurb = metadata.description().next().unwrap();
157 let previous = index.insert(name, blurb);
158 assert!(previous.is_none(), "Names should have been unique");
159 }
160 index
161}
162
163/// A help topic to describe a category of callables.
164struct CategoryTopic {

Callers 1

newMethod · 0.85

Calls 7

categoryMethod · 0.80
firstMethod · 0.80
return_typeMethod · 0.80
descriptionMethod · 0.80
nameMethod · 0.45
nextMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected