Skip to content

Commit

Permalink
DOCS: navigate back to rule overview linter
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrugman committed Sep 16, 2024
1 parent 3b57faf commit fbb3e3c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion crates/ruff_dev/src/generate_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::path::PathBuf;
use anyhow::Result;
use regex::{Captures, Regex};
use strum::IntoEnumIterator;
use itertools::Itertools;

use ruff_diagnostics::FixAvailability;
use ruff_linter::registry::{Linter, Rule, RuleNamespace};
Expand All @@ -33,7 +34,18 @@ pub(crate) fn main(args: &Args) -> Result<()> {

let (linter, _) = Linter::parse_code(&rule.noqa_code().to_string()).unwrap();
if linter.url().is_some() {
output.push_str(&format!("Derived from the **{}** linter.", linter.name()));
let codes_dsv: 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(), codes_dsv.to_lowercase());

output.push_str(&format!("Derived from the **[{}](../rules.md#{})** linter.", linter.name(), anchor));
output.push('\n');
output.push('\n');
}
Expand Down

0 comments on commit fbb3e3c

Please sign in to comment.