(
providers: Vec<Box<dyn DocProvider>>,
doc_sections: Vec<DocSection>,
)
| 91 | |
| 92 | #[expect(clippy::needless_pass_by_value)] |
| 93 | fn print_docs( |
| 94 | providers: Vec<Box<dyn DocProvider>>, |
| 95 | doc_sections: Vec<DocSection>, |
| 96 | ) -> Result<String> { |
| 97 | let mut docs = "".to_string(); |
| 98 | |
| 99 | // Ensure that all providers have documentation |
| 100 | let mut providers_with_no_docs = HashSet::new(); |
| 101 | |
| 102 | // doc sections only includes sections that have 'include' == true |
| 103 | for doc_section in doc_sections { |
| 104 | // make sure there is at least one function that is in this doc section |
| 105 | if !&providers.iter().any(|f| { |
| 106 | if let Some(documentation) = f.get_documentation() { |
| 107 | documentation.doc_section == doc_section |
| 108 | } else { |
| 109 | false |
| 110 | } |
| 111 | }) { |
| 112 | continue; |
| 113 | } |
| 114 | |
| 115 | // filter out functions that are not in this doc section |
| 116 | let providers: Vec<&Box<dyn DocProvider>> = providers |
| 117 | .iter() |
| 118 | .filter(|&f| { |
| 119 | if let Some(documentation) = f.get_documentation() { |
| 120 | documentation.doc_section == doc_section |
| 121 | } else { |
| 122 | providers_with_no_docs.insert(f.get_name()); |
| 123 | false |
| 124 | } |
| 125 | }) |
| 126 | .collect::<Vec<_>>(); |
| 127 | |
| 128 | // write out section header |
| 129 | let _ = writeln!(docs, "\n## {} \n", doc_section.label); |
| 130 | |
| 131 | if let Some(description) = doc_section.description { |
| 132 | let _ = writeln!(docs, "{description}"); |
| 133 | } |
| 134 | |
| 135 | // names is a sorted list of function names and aliases since we display |
| 136 | // both in the documentation |
| 137 | let names = get_names_and_aliases(&providers); |
| 138 | |
| 139 | // write out the list of function names and aliases |
| 140 | names.iter().for_each(|name| { |
| 141 | let _ = writeln!(docs, "- [{name}](#{name})"); |
| 142 | }); |
| 143 | |
| 144 | // write out each function and alias in the order of the sorted name list |
| 145 | for name in names { |
| 146 | let f = providers |
| 147 | .iter() |
| 148 | .find(|f| f.get_name() == name || f.get_aliases().contains(&name)) |
| 149 | .unwrap(); |
| 150 |
no test coverage detected
searching dependent graphs…