diff options
| author | Yotam Ofek <yotam.ofek@gmail.com> | 2025-02-15 22:49:00 +0000 |
|---|---|---|
| committer | Yotam Ofek <yotam.ofek@gmail.com> | 2025-03-01 10:31:46 +0000 |
| commit | 94645f6d102b2e7e720ffa1c759069c378bfd219 (patch) | |
| tree | 7bed837bac9b7f8528c7831380899a3a3399059b | |
| parent | 11e7aaf6e4841274a8023020943e9458700ae3a3 (diff) | |
jsondocck: catch and error on deprecated syntax
| -rw-r--r-- | src/tools/jsondocck/src/main.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/tools/jsondocck/src/main.rs b/src/tools/jsondocck/src/main.rs index 3f3a524217a..54249fbd9ae 100644 --- a/src/tools/jsondocck/src/main.rs +++ b/src/tools/jsondocck/src/main.rs @@ -166,6 +166,18 @@ static LINE_PATTERN: LazyLock<Regex> = LazyLock::new(|| { .unwrap() }); +static DEPRECATED_LINE_PATTERN: LazyLock<Regex> = LazyLock::new(|| { + RegexBuilder::new( + r#" + //\s+@ + "#, + ) + .ignore_whitespace(true) + .unicode(true) + .build() + .unwrap() +}); + fn print_err(msg: &str, lineno: usize) { eprintln!("Invalid command: {} on line {}", msg, lineno) } @@ -183,6 +195,12 @@ fn get_commands(template: &str) -> Result<Vec<Command>, ()> { for (lineno, line) in file.split('\n').enumerate() { let lineno = lineno + 1; + if DEPRECATED_LINE_PATTERN.is_match(line) { + print_err("Deprecated command syntax, replace `// @` with `//@ `", lineno); + errors = true; + continue; + } + let Some(cap) = LINE_PATTERN.captures(line) else { continue; }; |
