mod analyze;
mod blocks;
mod fence;
mod lines;
mod links;
mod vocabulary;
use std::path::Path;
use crate::analysis::findings::Finding;
use crate::docs::{Check, analyze};
fn run(content: &str) -> Vec<Finding> {
analyze(Path::new("doc.md"), content)
}
fn of_kind(content: &str, check: Check) -> Vec<Finding> {
run(content)
.into_iter()
.filter(|f| f.kind == check.as_str())
.collect()
}
fn positions(content: &str, check: Check) -> Vec<(u32, u32)> {
of_kind(content, check)
.into_iter()
.map(|f| {
(
f.line,
f.column.expect("every doc finding carries a column"),
)
})
.collect()
}
#[track_caller]
fn fires_once_at(content: &str, check: Check, line: u32, column: u32) {
assert_eq!(
positions(content, check),
vec![(line, column)],
"{} over {content:?}",
check.as_str()
);
}
#[track_caller]
fn silent(content: &str, check: Check) {
assert_eq!(
positions(content, check),
Vec::new(),
"{} should not fire over {content:?}",
check.as_str()
);
}
fn wide(n: usize) -> String {
"x".repeat(n)
}