Generates the index for a collection of `CallableMetadata`s to use in a `CategoryTopic`.
(metadatas: &[Rc<CallableMetadata>])
| 140 | |
| 141 | /// Generates the index for a collection of `CallableMetadata`s to use in a `CategoryTopic`. |
| 142 | fn 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. |
| 164 | struct CategoryTopic { |
no test coverage detected