Add documentation for flake8-quotes rules (#2650)

This commit is contained in:
Charlie Marsh 2023-02-07 21:20:24 -05:00 committed by GitHub
parent 367f115d83
commit a9aa96b24f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 192 additions and 8 deletions

View file

@ -4,11 +4,10 @@
use std::fs;
use anyhow::Result;
use ruff::registry::{Linter, Rule, RuleNamespace};
use ruff::AutofixAvailability;
use strum::IntoEnumIterator;
use ruff::registry::{Linter, Rule, RuleNamespace};
#[derive(clap::Args)]
pub struct Args {
/// Write the generated docs to stdout (rather than to the filesystem).
@ -22,10 +21,12 @@ pub fn main(args: &Args) -> Result<()> {
let mut output = String::new();
output.push_str(&format!("# {} ({})", rule.as_ref(), rule.code()));
output.push('\n');
output.push('\n');
let (linter, _) = Linter::parse_code(rule.code()).unwrap();
output.push_str(&format!("Derived from the **{}** linter.", linter.name()));
output.push('\n');
output.push('\n');
if let Some(autofix) = rule.autofixable() {
output.push_str(match autofix.available {
@ -33,6 +34,7 @@ pub fn main(args: &Args) -> Result<()> {
AutofixAvailability::Always => "Autofix is always available.",
});
output.push('\n');
output.push('\n');
}
output.push_str(explanation.trim());