mirror of
https://github.com/Noratrieb/target-tier-docs-experiment.git
synced 2026-01-14 16:35:09 +01:00
cleanup
This commit is contained in:
parent
8590f9b343
commit
a6884454c0
1 changed files with 33 additions and 71 deletions
104
src/render.rs
104
src/render.rs
|
|
@ -168,45 +168,48 @@ fn render_platform_support_tables(
|
||||||
content: &str,
|
content: &str,
|
||||||
targets: &[(TargetDocs, RustcTargetInfo)],
|
targets: &[(TargetDocs, RustcTargetInfo)],
|
||||||
) -> Result<String> {
|
) -> Result<String> {
|
||||||
let tier1host_table = render_table_awesome(
|
let replace_table = |content, name, tier_table| -> Result<String> {
|
||||||
targets,
|
let section_string = render_table(targets, tier_table)?;
|
||||||
|
replace_section(content, name, §ion_string).wrap_err("replacing platform support.md")
|
||||||
|
};
|
||||||
|
|
||||||
|
let content = replace_table(
|
||||||
|
content,
|
||||||
|
"TIER1HOST",
|
||||||
TierTable {
|
TierTable {
|
||||||
filter: |target| target.tier == Some(Tier::One),
|
filter: |target| target.tier == Some(Tier::One),
|
||||||
include_host: false,
|
include_host: false,
|
||||||
include_std: false,
|
include_std: false,
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
let tier2host_table = render_table(
|
let content = replace_table(
|
||||||
targets
|
&content,
|
||||||
.into_iter()
|
"TIER2HOST",
|
||||||
.filter(|target| target.0.tier == Some(Tier::Two) && target.0.has_host_tools()),
|
TierTable {
|
||||||
false,
|
filter: |target| target.tier == Some(Tier::Two) && target.has_host_tools(),
|
||||||
false,
|
include_host: false,
|
||||||
|
include_std: false,
|
||||||
|
},
|
||||||
)?;
|
)?;
|
||||||
let tier2_table = render_table(
|
let content = replace_table(
|
||||||
targets
|
&content,
|
||||||
.into_iter()
|
"TIER2",
|
||||||
.filter(|target| target.0.tier == Some(Tier::Two) && !target.0.has_host_tools()),
|
TierTable {
|
||||||
true,
|
filter: |target| target.tier == Some(Tier::Two) && !target.has_host_tools(),
|
||||||
false,
|
include_host: false,
|
||||||
|
include_std: true,
|
||||||
|
},
|
||||||
)?;
|
)?;
|
||||||
let tier3_table = render_table(
|
let content = replace_table(
|
||||||
targets
|
&content,
|
||||||
.into_iter()
|
"TIER3",
|
||||||
.filter(|target| target.0.tier == Some(Tier::Three)),
|
TierTable {
|
||||||
true,
|
filter: |target| target.tier == Some(Tier::Three),
|
||||||
true,
|
include_host: true,
|
||||||
|
include_std: true,
|
||||||
|
},
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let content = replace_section(&content, "TIER1HOST", &tier1host_table)
|
|
||||||
.wrap_err("replacing platform support.md")?;
|
|
||||||
let content = replace_section(&content, "TIER2HOST", &tier2host_table)
|
|
||||||
.wrap_err("replacing platform support.md")?;
|
|
||||||
let content = replace_section(&content, "TIER2", &tier2_table)
|
|
||||||
.wrap_err("replacing platform support.md")?;
|
|
||||||
let content = replace_section(&content, "TIER3", &tier3_table)
|
|
||||||
.wrap_err("replacing platform support.md")?;
|
|
||||||
|
|
||||||
Ok(content)
|
Ok(content)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -224,10 +227,7 @@ struct TierTable {
|
||||||
include_host: bool,
|
include_host: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_table_awesome<'a>(
|
fn render_table<'a>(targets: &[(TargetDocs, RustcTargetInfo)], table: TierTable) -> Result<String> {
|
||||||
targets: &[(TargetDocs, RustcTargetInfo)],
|
|
||||||
table: TierTable,
|
|
||||||
) -> Result<String> {
|
|
||||||
let mut rows = Vec::new();
|
let mut rows = Vec::new();
|
||||||
let mut all_footnotes = Vec::new();
|
let mut all_footnotes = Vec::new();
|
||||||
|
|
||||||
|
|
@ -290,41 +290,3 @@ fn render_table_awesome<'a>(
|
||||||
|
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_table<'a>(
|
|
||||||
targets: impl IntoIterator<Item = &'a (TargetDocs, RustcTargetInfo)>,
|
|
||||||
include_std: bool,
|
|
||||||
include_host: bool,
|
|
||||||
) -> Result<String> {
|
|
||||||
let mut rows = Vec::new();
|
|
||||||
|
|
||||||
for (target, _) in targets {
|
|
||||||
let meta = target.metadata.as_ref();
|
|
||||||
|
|
||||||
let notes = meta.map(|meta| meta.notes.as_str()).unwrap_or("unknown");
|
|
||||||
let std = if include_std {
|
|
||||||
let std = meta
|
|
||||||
.map(|meta| render_table_tri_state_bool(meta.std))
|
|
||||||
.unwrap_or("?");
|
|
||||||
format!(" | {std}")
|
|
||||||
} else {
|
|
||||||
String::new()
|
|
||||||
};
|
|
||||||
|
|
||||||
let host = if include_host {
|
|
||||||
let host = meta
|
|
||||||
.map(|meta| render_table_tri_state_bool(meta.host))
|
|
||||||
.unwrap_or("?");
|
|
||||||
format!(" | {host}")
|
|
||||||
} else {
|
|
||||||
String::new()
|
|
||||||
};
|
|
||||||
|
|
||||||
rows.push(format!(
|
|
||||||
"[`{0}`](platform-support/targets/{0}.md){std}{host} | {notes}",
|
|
||||||
target.name
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(rows.join("\n"))
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue