mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
Reference related settings in rules (#4157)
This commit is contained in:
parent
2d6d51f3a1
commit
a4ce746892
1 changed files with 17 additions and 2 deletions
|
@ -1,10 +1,12 @@
|
|||
//! Generate a Markdown-compatible table of supported lint rules.
|
||||
|
||||
use itertools::Itertools;
|
||||
use ruff::registry::{Linter, Rule, RuleNamespace, UpstreamCategory};
|
||||
use ruff_diagnostics::AutofixKind;
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
use ruff::registry::{Linter, Rule, RuleNamespace, UpstreamCategory};
|
||||
use ruff::settings::options::Options;
|
||||
use ruff_diagnostics::AutofixKind;
|
||||
|
||||
const FIX_SYMBOL: &str = "🛠";
|
||||
|
||||
fn generate_table(table_out: &mut String, rules: impl IntoIterator<Item = Rule>, linter: &Linter) {
|
||||
|
@ -78,6 +80,19 @@ pub fn generate() -> String {
|
|||
table_out.push('\n');
|
||||
}
|
||||
|
||||
if Options::metadata()
|
||||
.iter()
|
||||
.any(|(name, _)| name == &linter.name())
|
||||
{
|
||||
table_out.push_str(&format!(
|
||||
"For related settings, see [{}](settings.md#{}).",
|
||||
linter.name(),
|
||||
linter.name(),
|
||||
));
|
||||
table_out.push('\n');
|
||||
table_out.push('\n');
|
||||
}
|
||||
|
||||
if let Some(categories) = linter.upstream_categories() {
|
||||
for UpstreamCategory(prefix, name) in categories {
|
||||
table_out.push_str(&format!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue