@@ -18,44 +18,43 @@ const FIX_SYMBOL: &str = "🛠️";
18
18
const PREVIEW_SYMBOL : & str = "🧪" ;
19
19
const REMOVED_SYMBOL : & str = "❌" ;
20
20
const WARNING_SYMBOL : & str = "⚠️" ;
21
- const STABLE_SYMBOL : & str = "✔️" ;
22
21
const SPACER : & str = " " ;
23
22
23
+ /// Style for the rule's fixability and status icons.
24
+ const SYMBOL_STYLE : & str = "style='width: 1em; display: inline-block;'" ;
25
+ /// Style for the container wrapping the fixability and status icons.
26
+ const SYMBOLS_CONTAINER : & str = "style='display: flex; gap: 0.5rem; justify-content: end;'" ;
27
+
24
28
fn generate_table ( table_out : & mut String , rules : impl IntoIterator < Item = Rule > , linter : & Linter ) {
25
- table_out. push_str ( "| Code | Name | Message | |" ) ;
29
+ table_out. push_str ( "| Code | Name | Message | |" ) ;
26
30
table_out. push ( '\n' ) ;
27
- table_out. push_str ( "| ---- | ---- | ------- | ------ : |" ) ;
31
+ table_out. push_str ( "| ---- | ---- | ------- | -: |" ) ;
28
32
table_out. push ( '\n' ) ;
29
33
for rule in rules {
30
34
let status_token = match rule. group ( ) {
31
35
RuleGroup :: Removed => {
32
- format ! ( "<span title='Rule has been removed'>{REMOVED_SYMBOL}</span>" )
36
+ format ! (
37
+ "<span {SYMBOL_STYLE} title='Rule has been removed'>{REMOVED_SYMBOL}</span>"
38
+ )
33
39
}
34
40
RuleGroup :: Deprecated => {
35
- format ! ( "<span title='Rule has been deprecated'>{WARNING_SYMBOL}</span>" )
41
+ format ! (
42
+ "<span {SYMBOL_STYLE} title='Rule has been deprecated'>{WARNING_SYMBOL}</span>"
43
+ )
36
44
}
37
45
RuleGroup :: Preview => {
38
- format ! ( "<span title='Rule is in preview'>{PREVIEW_SYMBOL}</span>" )
39
- }
40
- RuleGroup :: Stable => {
41
- // A full opacity checkmark is a bit aggressive for indicating stable
42
- format ! ( "<span title='Rule is stable' style='opacity: 0.6'>{STABLE_SYMBOL}</span>" )
46
+ format ! ( "<span {SYMBOL_STYLE} title='Rule is in preview'>{PREVIEW_SYMBOL}</span>" )
43
47
}
48
+ RuleGroup :: Stable => format ! ( "<span {SYMBOL_STYLE}></span>" ) ,
44
49
} ;
45
50
46
51
let fix_token = match rule. fixable ( ) {
47
52
FixAvailability :: Always | FixAvailability :: Sometimes => {
48
- format ! ( "<span title='Automatic fix available'>{FIX_SYMBOL}</span>" )
49
- }
50
- FixAvailability :: None => {
51
- format ! (
52
- "<span title='Automatic fix not available' style='opacity: 0.1' aria-hidden='true'>{FIX_SYMBOL}</span>"
53
- )
53
+ format ! ( "<span {SYMBOL_STYLE} title='Automatic fix available'>{FIX_SYMBOL}</span>" )
54
54
}
55
+ FixAvailability :: None => format ! ( "<span {SYMBOL_STYLE}></span>" ) ,
55
56
} ;
56
57
57
- let tokens = format ! ( "{status_token} {fix_token}" ) ;
58
-
59
58
let rule_name = rule. as_ref ( ) ;
60
59
61
60
// If the message ends in a bracketed expression (like: "Use {replacement}"), escape the
@@ -82,15 +81,14 @@ fn generate_table(table_out: &mut String, rules: impl IntoIterator<Item = Rule>,
82
81
#[ expect( clippy:: or_fun_call) ]
83
82
let _ = write ! (
84
83
table_out,
85
- "| {ss}{0}{1}{se} {{ #{0}{1} }} | {ss}{2}{se} | {ss}{3}{se} | {ss}{4}{se} |" ,
86
- linter. common_prefix( ) ,
87
- linter. code_for_rule( rule) . unwrap( ) ,
88
- rule. explanation( )
84
+ "| {ss}{prefix}{code}{se} {{ #{prefix}{code} }} | {ss}{explanation}{se} | {ss}{message}{se} | <div {SYMBOLS_CONTAINER}>{status_token}{fix_token}</div>|" ,
85
+ prefix = linter. common_prefix( ) ,
86
+ code = linter. code_for_rule( rule) . unwrap( ) ,
87
+ explanation = rule
88
+ . explanation( )
89
89
. is_some( )
90
90
. then_some( format_args!( "[{rule_name}](rules/{rule_name}.md)" ) )
91
91
. unwrap_or( format_args!( "{rule_name}" ) ) ,
92
- message,
93
- tokens,
94
92
) ;
95
93
table_out. push ( '\n' ) ;
96
94
}
@@ -104,12 +102,6 @@ pub(crate) fn generate() -> String {
104
102
table_out. push_str ( "### Legend" ) ;
105
103
table_out. push ( '\n' ) ;
106
104
107
- let _ = write ! (
108
- & mut table_out,
109
- "{SPACER}{STABLE_SYMBOL}{SPACER} The rule is stable."
110
- ) ;
111
- table_out. push_str ( "<br />" ) ;
112
-
113
105
let _ = write ! (
114
106
& mut table_out,
115
107
"{SPACER}{PREVIEW_SYMBOL}{SPACER} The rule is unstable and is in [\" preview\" ](faq.md#what-is-preview)."
@@ -132,7 +124,8 @@ pub(crate) fn generate() -> String {
132
124
& mut table_out,
133
125
"{SPACER}{FIX_SYMBOL}{SPACER} The rule is automatically fixable by the `--fix` command-line option."
134
126
) ;
135
- table_out. push_str ( "<br />" ) ;
127
+ table_out. push_str ( "\n \n " ) ;
128
+ table_out. push_str ( "All rules not marked as preview, deprecated or removed are stable." ) ;
136
129
table_out. push ( '\n' ) ;
137
130
138
131
for linter in Linter :: iter ( ) {
0 commit comments