ruff/ruff_dev/src
Martin Fischer 4758ee6ac4 refactor: Generate Linter -> RuleSelector mapping via macro
To enable ruff_dev to automatically generate the rule Markdown tables in
the README the ruff library contained the following function:

    Linter::codes() -> Vec<RuleSelector>

which was slightly changed to `fn prefixes(&self) -> Prefixes` in
9dc66b5a65 to enable ruff_dev to split
up the Markdown tables for linters that have multiple prefixes
(pycodestyle has E & W, Pylint has PLC, PLE, PLR & PLW).

The definition of this method was however largely redundant with the
#[prefix] macro attributes in the Linter enum, which are used to
derive the Linter::parse_code function, used by the --explain command.

This commit removes the redundant Linter::prefixes by introducing a
same-named method with a different signature to the RuleNamespace trait:

     fn prefixes(&self) -> &'static [&'static str];

As well as implementing IntoIterator<Rule> for &Linter. We extend the
extisting RuleNamespace proc macro to automatically derive both
implementations from the Linter enum definition.

To support the previously mentioned Markdown table splitting we
introduce a very simple hand-written method to the Linter impl:

    fn categories(&self) -> Option<&'static [LinterCategory]>;
2023-01-22 11:51:29 -05:00
..
generate_all.rs Add proc-macro to derive `CheckCodePrefix` (#1656) 2023-01-05 11:39:16 -05:00
generate_cli_help.rs Reduce the API of ruff_cli to ruff_cli::help() 2023-01-14 10:11:30 -05:00
generate_json_schema.rs Add cargo +nightly dev generate-all (#1404) 2022-12-27 10:07:18 -05:00
generate_options.rs Generate the README's --help output automatically via cargo +nightly dev generate-all (#1483) 2022-12-30 15:06:32 -05:00
generate_rules_table.rs refactor: Generate Linter -> RuleSelector mapping via macro 2023-01-22 11:51:29 -05:00
main.rs Add top-level doc comments for crates 2023-01-14 10:11:30 -05:00
print_ast.rs Fix clippy::uninlined_format_args (pedantic) 2022-11-21 23:22:28 -05:00
print_cst.rs Convert Err(anyhow(...)) to bail (#984) 2022-12-01 13:33:06 -05:00
print_tokens.rs Fix clippy::uninlined_format_args (pedantic) 2022-11-21 23:22:28 -05:00
round_trip.rs Make ruff::source_code::{Generator, Locator, Stylist} private 2023-01-14 18:23:59 -05:00
utils.rs Generate the README's --help output automatically via cargo +nightly dev generate-all (#1483) 2022-12-30 15:06:32 -05:00