Reference related settings in rules (#4157)

This commit is contained in:
Calum Young 2023-05-02 01:59:00 +01:00 committed by GitHub
parent 2d6d51f3a1
commit a4ce746892
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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!(