mirror of https://github.com/astral-sh/ruff
Reference related settings in rules (#4157)
This commit is contained in:
parent
2d6d51f3a1
commit
a4ce746892
|
|
@ -1,10 +1,12 @@
|
||||||
//! Generate a Markdown-compatible table of supported lint rules.
|
//! Generate a Markdown-compatible table of supported lint rules.
|
||||||
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use ruff::registry::{Linter, Rule, RuleNamespace, UpstreamCategory};
|
|
||||||
use ruff_diagnostics::AutofixKind;
|
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
|
use ruff::registry::{Linter, Rule, RuleNamespace, UpstreamCategory};
|
||||||
|
use ruff::settings::options::Options;
|
||||||
|
use ruff_diagnostics::AutofixKind;
|
||||||
|
|
||||||
const FIX_SYMBOL: &str = "🛠";
|
const FIX_SYMBOL: &str = "🛠";
|
||||||
|
|
||||||
fn generate_table(table_out: &mut String, rules: impl IntoIterator<Item = Rule>, linter: &Linter) {
|
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');
|
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() {
|
if let Some(categories) = linter.upstream_categories() {
|
||||||
for UpstreamCategory(prefix, name) in categories {
|
for UpstreamCategory(prefix, name) in categories {
|
||||||
table_out.push_str(&format!(
|
table_out.push_str(&format!(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue