mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-19 00:30:33 +00:00
Merge registry into codes (#4651)
* Document codes.rs * Refactor codes.rs before merging Helper script: ```python # %% from pathlib import Path codes = Path("crates/ruff/src/codes.rs").read_text().splitlines() rules = Path("a.txt").read_text().strip().splitlines() rule_map = {i.split("::")[-1]: i for i in rules} # %% codes_new = [] for line in codes: if ", Rule::" in line: left, right = line.split(", Rule::") right = right[:-2] line = left + ", " + rule_map[right] + ")," codes_new.append(line) # %% Path("crates/ruff/src/codes.rs").write_text("\n".join(codes_new)) ``` Co-authored-by: Jonathan Plasse <13716151+JonathanPlasse@users.noreply.github.com>
This commit is contained in:
parent
c4fdbf8903
commit
602b4b3519
9 changed files with 847 additions and 1610 deletions
|
@ -11,7 +11,6 @@ mod config;
|
|||
mod derive_message_formats;
|
||||
mod map_codes;
|
||||
mod newtype_index;
|
||||
mod register_rules;
|
||||
mod rule_code_prefix;
|
||||
mod rule_namespace;
|
||||
mod violation;
|
||||
|
@ -44,12 +43,6 @@ pub fn cache_key(input: TokenStream) -> TokenStream {
|
|||
TokenStream::from(stream)
|
||||
}
|
||||
|
||||
#[proc_macro]
|
||||
pub fn register_rules(item: TokenStream) -> TokenStream {
|
||||
let mapping = parse_macro_input!(item as register_rules::Input);
|
||||
register_rules::register_rules(&mapping).into()
|
||||
}
|
||||
|
||||
/// Adds an `explanation()` method from the doc comment.
|
||||
#[proc_macro_attribute]
|
||||
pub fn violation(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue