mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 12:29:28 +00:00
DOCS: navigate back to rule overview linter (#13368)
This commit is contained in:
parent
3b57faf19b
commit
bb12fe9d0c
1 changed files with 21 additions and 1 deletions
|
@ -6,6 +6,7 @@ use std::fs;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use itertools::Itertools;
|
||||||
use regex::{Captures, Regex};
|
use regex::{Captures, Regex};
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
|
@ -33,7 +34,26 @@ pub(crate) fn main(args: &Args) -> Result<()> {
|
||||||
|
|
||||||
let (linter, _) = Linter::parse_code(&rule.noqa_code().to_string()).unwrap();
|
let (linter, _) = Linter::parse_code(&rule.noqa_code().to_string()).unwrap();
|
||||||
if linter.url().is_some() {
|
if linter.url().is_some() {
|
||||||
output.push_str(&format!("Derived from the **{}** linter.", linter.name()));
|
let common_prefix: String = match linter.common_prefix() {
|
||||||
|
"" => linter
|
||||||
|
.upstream_categories()
|
||||||
|
.unwrap()
|
||||||
|
.iter()
|
||||||
|
.map(|c| c.prefix)
|
||||||
|
.join("-"),
|
||||||
|
prefix => prefix.to_string(),
|
||||||
|
};
|
||||||
|
let anchor = format!(
|
||||||
|
"{}-{}",
|
||||||
|
linter.name().to_lowercase(),
|
||||||
|
common_prefix.to_lowercase()
|
||||||
|
);
|
||||||
|
|
||||||
|
output.push_str(&format!(
|
||||||
|
"Derived from the **[{}](../rules.md#{})** linter.",
|
||||||
|
linter.name(),
|
||||||
|
anchor
|
||||||
|
));
|
||||||
output.push('\n');
|
output.push('\n');
|
||||||
output.push('\n');
|
output.push('\n');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue