tidy: skip lines starting with #
in alphabetical check.
These are comment lines in `Cargo.toml` files. But exclude lines starting with `#!` from the skipping, because we want to check them. (Rust `#![feature(...)]` lines.) Also allow empty lines, which are occasionally useful.
This commit is contained in:
parent
b7bea6e46f
commit
40797eef5e
@ -10,9 +10,10 @@
|
|||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! The following lines are ignored:
|
//! The following lines are ignored:
|
||||||
|
//! - Empty lines
|
||||||
//! - Lines that are indented with more or less spaces than the first line
|
//! - Lines that are indented with more or less spaces than the first line
|
||||||
//! - Lines starting with `//`, `#[`, `)`, `]`, `}` if the comment has the same indentation as
|
//! - Lines starting with `//`, `#` (except those starting with `#!`), `)`, `]`, `}` if the comment
|
||||||
//! the first line
|
//! has the same indentation as the first line
|
||||||
//!
|
//!
|
||||||
//! If a line ends with an opening bracket, the line is ignored and the next line will have
|
//! If a line ends with an opening bracket, the line is ignored and the next line will have
|
||||||
//! its extra indentation ignored.
|
//! its extra indentation ignored.
|
||||||
@ -43,6 +44,10 @@ fn check_section<'a>(
|
|||||||
let mut in_split_line = None;
|
let mut in_split_line = None;
|
||||||
|
|
||||||
for (line_idx, line) in lines {
|
for (line_idx, line) in lines {
|
||||||
|
if line.is_empty() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if line.contains(START_MARKER) {
|
if line.contains(START_MARKER) {
|
||||||
tidy_error!(bad, "{file}:{} found `{START_MARKER}` expecting `{END_MARKER}`", line_idx)
|
tidy_error!(bad, "{file}:{} found `{START_MARKER}` expecting `{END_MARKER}`", line_idx)
|
||||||
}
|
}
|
||||||
@ -71,7 +76,7 @@ fn check_section<'a>(
|
|||||||
let trimmed_line = line.trim_start_matches(' ');
|
let trimmed_line = line.trim_start_matches(' ');
|
||||||
|
|
||||||
if trimmed_line.starts_with("//")
|
if trimmed_line.starts_with("//")
|
||||||
|| trimmed_line.starts_with("#[")
|
|| (trimmed_line.starts_with("#") && !trimmed_line.starts_with("#!"))
|
||||||
|| trimmed_line.starts_with(is_close_bracket)
|
|| trimmed_line.starts_with(is_close_bracket)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user