mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
Create per-rule pages and link from README (#2644)
This commit is contained in:
parent
f1cdd108e6
commit
271e4fda8c
17 changed files with 156 additions and 40 deletions
|
@ -37,7 +37,8 @@ impl Parse for LintMeta {
|
|||
let value = lit.value();
|
||||
let line = value.strip_prefix(' ').unwrap_or(&value);
|
||||
if line.starts_with("```") {
|
||||
explanation += "```\n";
|
||||
explanation += line;
|
||||
explanation.push('\n');
|
||||
in_code = !in_code;
|
||||
} else if !(in_code && line.starts_with("# ")) {
|
||||
explanation += line;
|
||||
|
@ -61,15 +62,21 @@ impl Parse for LintMeta {
|
|||
|
||||
pub fn define_violation(input: &TokenStream, meta: LintMeta) -> TokenStream {
|
||||
let LintMeta { explanation, name } = meta;
|
||||
let output = quote! {
|
||||
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#input
|
||||
if explanation.is_empty() {
|
||||
quote! {
|
||||
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#input
|
||||
}
|
||||
} else {
|
||||
quote! {
|
||||
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#input
|
||||
|
||||
impl #name {
|
||||
pub fn explanation() -> Option<&'static str> {
|
||||
Some(#explanation)
|
||||
impl #name {
|
||||
pub fn explanation() -> Option<&'static str> {
|
||||
Some(#explanation)
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
output
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue