mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-09 18:02:19 +00:00
Remove mdcat dependency (#2959)
This commit is contained in:
parent
fdcb78fd8c
commit
370c3a5daf
5 changed files with 6 additions and 850 deletions
795
Cargo.lock
generated
795
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -42,10 +42,8 @@ glob = { version = "0.3.0" }
|
||||||
ignore = { version = "0.4.18" }
|
ignore = { version = "0.4.18" }
|
||||||
itertools = { workspace = true }
|
itertools = { workspace = true }
|
||||||
log = { version = "0.4.17" }
|
log = { version = "0.4.17" }
|
||||||
mdcat = { version = "1.0.0", default-features = false }
|
|
||||||
notify = { version = "5.0.0" }
|
notify = { version = "5.0.0" }
|
||||||
path-absolutize = { version = "3.0.14", features = ["once_cell_cache"] }
|
path-absolutize = { version = "3.0.14", features = ["once_cell_cache"] }
|
||||||
pulldown-cmark = { version = "0.9.2", default-features = false, features = ['simd'] }
|
|
||||||
quick-junit = { version = "0.3.2" }
|
quick-junit = { version = "0.3.2" }
|
||||||
rayon = { version = "1.5.3" }
|
rayon = { version = "1.5.3" }
|
||||||
regex = { workspace = true }
|
regex = { workspace = true }
|
||||||
|
@ -54,7 +52,6 @@ serde = { workspace = true }
|
||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
similar = { version = "2.2.1" }
|
similar = { version = "2.2.1" }
|
||||||
strum = { version = "0.24.1" }
|
strum = { version = "0.24.1" }
|
||||||
syntect = { version = "5.0.0", default-features = false, features = ["parsing", "regex-fancy", "default-themes", "default-syntaxes"] }
|
|
||||||
textwrap = { version = "0.16.0" }
|
textwrap = { version = "0.16.0" }
|
||||||
walkdir = { version = "2.3.2" }
|
walkdir = { version = "2.3.2" }
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ pub enum Command {
|
||||||
rule: Rule,
|
rule: Rule,
|
||||||
|
|
||||||
/// Output format
|
/// Output format
|
||||||
#[arg(long, value_enum, default_value = "pretty")]
|
#[arg(long, value_enum, default_value = "text")]
|
||||||
format: HelpFormat,
|
format: HelpFormat,
|
||||||
},
|
},
|
||||||
/// List or describe the available configuration options
|
/// List or describe the available configuration options
|
||||||
|
@ -296,7 +296,6 @@ pub struct CheckArgs {
|
||||||
pub enum HelpFormat {
|
pub enum HelpFormat {
|
||||||
Text,
|
Text,
|
||||||
Json,
|
Json,
|
||||||
Pretty,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::module_name_repetitions)]
|
#[allow(clippy::module_name_repetitions)]
|
||||||
|
|
|
@ -63,24 +63,6 @@ pub fn linter(format: HelpFormat) -> Result<()> {
|
||||||
output.push_str(&serde_json::to_string_pretty(&linters)?);
|
output.push_str(&serde_json::to_string_pretty(&linters)?);
|
||||||
output.push('\n');
|
output.push('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
HelpFormat::Pretty => {
|
|
||||||
output.push_str(&format!("| {:>6} | {:<27} |\n", "Prefix", "Name"));
|
|
||||||
output.push_str(&format!("| {:>6} | {:<27} |\n", "------", "-".repeat(27)));
|
|
||||||
|
|
||||||
for linter in Linter::iter() {
|
|
||||||
let prefix = match linter.common_prefix() {
|
|
||||||
"" => linter
|
|
||||||
.upstream_categories()
|
|
||||||
.unwrap()
|
|
||||||
.iter()
|
|
||||||
.map(|UpstreamCategory(prefix, ..)| prefix.short_code())
|
|
||||||
.join("/"),
|
|
||||||
prefix => prefix.to_string(),
|
|
||||||
};
|
|
||||||
output.push_str(&format!("| {:>6} | {:<27} |\n", prefix, linter.name()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(stdout, "{output}")?;
|
write!(stdout, "{output}")?;
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
use std::io::{self, BufWriter, Write};
|
use std::io::{self, BufWriter, Write};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use colored::control::SHOULD_COLORIZE;
|
|
||||||
use mdcat::terminal::{TerminalProgram, TerminalSize};
|
|
||||||
use mdcat::{Environment, ResourceAccess, Settings};
|
|
||||||
use pulldown_cmark::{Options, Parser};
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use syntect::parsing::SyntaxSet;
|
|
||||||
|
|
||||||
use ruff::registry::{Linter, Rule, RuleNamespace};
|
use ruff::registry::{Linter, Rule, RuleNamespace};
|
||||||
use ruff::AutofixAvailability;
|
use ruff::AutofixAvailability;
|
||||||
|
@ -27,7 +22,7 @@ pub fn rule(rule: &Rule, format: HelpFormat) -> Result<()> {
|
||||||
let mut output = String::new();
|
let mut output = String::new();
|
||||||
|
|
||||||
match format {
|
match format {
|
||||||
HelpFormat::Text | HelpFormat::Pretty => {
|
HelpFormat::Text => {
|
||||||
output.push_str(&format!("# {} ({})", rule.as_ref(), rule.noqa_code()));
|
output.push_str(&format!("# {} ({})", rule.as_ref(), rule.noqa_code()));
|
||||||
output.push('\n');
|
output.push('\n');
|
||||||
output.push('\n');
|
output.push('\n');
|
||||||
|
@ -65,35 +60,7 @@ pub fn rule(rule: &Rule, format: HelpFormat) -> Result<()> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
match format {
|
|
||||||
HelpFormat::Json | HelpFormat::Text => {
|
|
||||||
writeln!(stdout, "{output}")?;
|
writeln!(stdout, "{output}")?;
|
||||||
}
|
|
||||||
HelpFormat::Pretty => {
|
|
||||||
let parser = Parser::new_ext(
|
|
||||||
&output,
|
|
||||||
Options::ENABLE_TASKLISTS | Options::ENABLE_STRIKETHROUGH,
|
|
||||||
);
|
|
||||||
|
|
||||||
let cwd = std::env::current_dir()?;
|
|
||||||
let env = &Environment::for_local_directory(&cwd)?;
|
|
||||||
|
|
||||||
let terminal = if SHOULD_COLORIZE.should_colorize() {
|
|
||||||
TerminalProgram::detect()
|
|
||||||
} else {
|
|
||||||
TerminalProgram::Dumb
|
|
||||||
};
|
|
||||||
|
|
||||||
let settings = &Settings {
|
|
||||||
resource_access: ResourceAccess::LocalOnly,
|
|
||||||
syntax_set: SyntaxSet::load_defaults_newlines(),
|
|
||||||
terminal_capabilities: terminal.capabilities(),
|
|
||||||
terminal_size: TerminalSize::detect().unwrap_or_default(),
|
|
||||||
};
|
|
||||||
|
|
||||||
mdcat::push_tty(settings, env, &mut stdout, parser)?;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue