Skip to content

Commit 94645f6

Browse files
committed
jsondocck: catch and error on deprecated syntax
1 parent 11e7aaf commit 94645f6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/tools/jsondocck/src/main.rs

+18
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,18 @@ static LINE_PATTERN: LazyLock<Regex> = LazyLock::new(|| {
166166
.unwrap()
167167
});
168168

169+
static DEPRECATED_LINE_PATTERN: LazyLock<Regex> = LazyLock::new(|| {
170+
RegexBuilder::new(
171+
r#"
172+
//\s+@
173+
"#,
174+
)
175+
.ignore_whitespace(true)
176+
.unicode(true)
177+
.build()
178+
.unwrap()
179+
});
180+
169181
fn print_err(msg: &str, lineno: usize) {
170182
eprintln!("Invalid command: {} on line {}", msg, lineno)
171183
}
@@ -183,6 +195,12 @@ fn get_commands(template: &str) -> Result<Vec<Command>, ()> {
183195
for (lineno, line) in file.split('\n').enumerate() {
184196
let lineno = lineno + 1;
185197

198+
if DEPRECATED_LINE_PATTERN.is_match(line) {
199+
print_err("Deprecated command syntax, replace `// @` with `//@ `", lineno);
200+
errors = true;
201+
continue;
202+
}
203+
186204
let Some(cap) = LINE_PATTERN.captures(line) else {
187205
continue;
188206
};

0 commit comments

Comments
 (0)