Repository navigation
Library
The dejadoc crate runs the same scan as the command line and returns the report as data.
[dependencies]
dejadoc = { version = "0.5", default-features = false, features = ["std"] }The default cli feature only adds the cargo dejadoc binary. Library users need std, which reads the workspace through cargo metadata and loads .dejadoc.toml.
let report = dejadoc::Dejadoc::default()
.functions()
.context_blocks()
.run(".")
.unwrap();
println!("{}", dejadoc::human(&report, false));Dejadoc takes the same settings as the Configuration page lists, one builder method each. Anything left unset falls back to the workspace's .dejadoc.toml and then to the defaults. Scanning compiles nothing and covers every cfg variant in one run.
Report holds the totals and the groups.
| Field | Holds |
|---|---|
groups |
Doctest groups, then function groups, each Group with its sites, the copy to keep first |
context_groups |
Approximate context matches, each ContextGroup with source ranges and no copy to keep |
total, unique
|
Doctests scanned and their distinct forms |
functions, unique_functions
|
Functions scanned and their distinct forms |
context_blocks, unique_context_blocks
|
Contexts scanned and their distinct forms |
A function Group also carries a Remedy, explained on the Checks page.
human renders the report as text, json as the JSON that --json prints, and annotations as GitHub workflow commands. exit_code turns a report into the exit status the command line uses.
The comparison lives in syn-canon, which works on any syn::File and runs in no_std with alloc. Use it to compare code dejadoc never sees, such as generated snippets.
let form = |source: &str| syn_canon::canonicalize(syn::parse_str(source).unwrap());
assert_eq!(
form("fn area(width: u32, height: u32) -> u32 { width * height }"),
form("fn product(a: u32, b: u32) -> u32 { return a * b; }"),
);canonicalize_failing builds the form for code meant to fail to compile, as in a compile_fail doctest, and keeps every spelling that matters for the failure. contexts emits the form of every function body, block, match arm and closure in a file. Equal forms compare equal and hash equally, and the key stays stable within one major version of syn-canon.