1use crate::{CitizenInfo, registered_citizens};
4
5pub fn citizen_census_markdown() -> String {
10 let mut citizens = registered_citizens().collect::<Vec<_>>();
11 citizens.sort_by(|left, right| {
12 left.symbol
13 .cmp(right.symbol)
14 .then_with(|| left.crate_name.cmp(right.crate_name))
15 });
16 render_citizen_census(&citizens)
17}
18
19pub fn render_citizen_census(citizens: &[&CitizenInfo]) -> String {
24 let mut out = String::new();
25 out.push_str("# Generated Citizen Census\n\n");
26 out.push_str("Generated by `cargo test --workspace --all-features citizen`.\n");
27 out.push_str("Do not edit by hand.\n\n");
28 out.push_str(&format!("Total citizens: {}\n\n", citizens.len()));
29 out.push_str("| Symbol | Version | Arity | Crate |\n");
30 out.push_str("| --- | ---: | ---: | --- |\n");
31 for info in citizens {
32 out.push_str(&format!(
33 "| `{}` | {} | {} | `{}` |\n",
34 info.symbol, info.version, info.arity, info.crate_name
35 ));
36 }
37 out
38}