mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 13:24:57 +00:00
Add documentation for mccabe, isort, and flake8-annotations (#2691)
This commit is contained in:
parent
8a98cfc4b8
commit
7d5fb0de8a
21 changed files with 713 additions and 23 deletions
|
@ -30,20 +30,13 @@ impl Parse for LintMeta {
|
|||
fn parse(input: ParseStream) -> Result<Self> {
|
||||
let attrs = input.call(Attribute::parse_outer)?;
|
||||
|
||||
let mut in_code = false;
|
||||
let mut explanation = String::new();
|
||||
for attr in &attrs {
|
||||
if let Some(lit) = parse_attr(["doc"], attr) {
|
||||
let value = lit.value();
|
||||
let line = value.strip_prefix(' ').unwrap_or(&value);
|
||||
if line.starts_with("```") {
|
||||
explanation += line;
|
||||
explanation.push('\n');
|
||||
in_code = !in_code;
|
||||
} else if !(in_code && line.starts_with("# ")) {
|
||||
explanation += line;
|
||||
explanation.push('\n');
|
||||
}
|
||||
explanation.push_str(line);
|
||||
explanation.push('\n');
|
||||
} else {
|
||||
return Err(Error::new_spanned(attr, "unexpected attribute"));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue