Add a link to the nursery; tweak icons (#5637)

## Summary

We now always render the icons, but very faintly if inactive, and always
right-align. This ensures consistent alignment as you scroll down the
page:

<img width="1792" alt="Screen Shot 2023-07-09 at 10 45 50 PM"
src="da47ac0e-d646-49e1-bbe1-9f43adf94bb4">
This commit is contained in:
Charlie Marsh 2023-07-09 23:09:08 -04:00 committed by GitHub
parent eb69fe37bf
commit c9d7c0d7d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 11 deletions

View file

@ -11,19 +11,21 @@ const FIX_SYMBOL: &str = "🛠";
const NURSERY_SYMBOL: &str = "🌅";
fn generate_table(table_out: &mut String, rules: impl IntoIterator<Item = Rule>, linter: &Linter) {
table_out.push_str("| Code | Name | Message | Status |");
table_out.push_str("| Code | Name | Message | |");
table_out.push('\n');
table_out.push_str("| ---- | ---- | ------- | ------ |");
table_out.push_str("| ---- | ---- | ------- | ------: |");
table_out.push('\n');
for rule in rules {
let fix_token = match rule.autofixable() {
AutofixKind::None => "",
AutofixKind::Always | AutofixKind::Sometimes => FIX_SYMBOL,
AutofixKind::Always | AutofixKind::Sometimes => {
format!("<span style='opacity: 1'>{FIX_SYMBOL}</span>")
}
AutofixKind::None => format!("<span style='opacity: 0.1'>{FIX_SYMBOL}</span>"),
};
let nursery_token = if rule.is_nursery() {
NURSERY_SYMBOL
format!("<span style='opacity: 1'>{NURSERY_SYMBOL}</span>")
} else {
""
format!("<span style='opacity: 0.1'>{NURSERY_SYMBOL}</span>")
};
let status_token = format!("{fix_token} {nursery_token}");
@ -48,10 +50,19 @@ fn generate_table(table_out: &mut String, rules: impl IntoIterator<Item = Rule>,
pub(crate) fn generate() -> String {
// Generate the table string.
let mut table_out = format!(
"The {FIX_SYMBOL} emoji indicates that a rule is automatically fixable by the `--fix` command-line option.\n\
The {NURSERY_SYMBOL} emoji indicates that a rule is part of the nursery, a collection of newer lints that are still under development.\n\n"
);
let mut table_out = String::new();
table_out.push_str(&format!(
"The {FIX_SYMBOL} emoji indicates that a rule is automatically fixable by the `--fix` command-line option."));
table_out.push('\n');
table_out.push('\n');
table_out.push_str(&format!(
"The {NURSERY_SYMBOL} emoji indicates that a rule is part of the [\"nursery\"](../faq/#what-is-the-nursery)."
));
table_out.push('\n');
table_out.push('\n');
for linter in Linter::iter() {
let codes_csv: String = match linter.common_prefix() {
"" => linter