Expand description
Format-neutral document diagnostics.
A document is read into a Node tree that keeps where each value was in the text. Problems
are Diagnostics with a stable Code, a Path, a place, a message and, where it can be
known, help and Fixes. A Report orders, groups and caps them for one document and
renders them as text. Nothing here knows an alpha2 document type: the project and compose
packs in alpha2-model and alpha2-compose bring their schemas, rules and judges.
Modules§
- advise
- Advisors: help lines and fixes added to diagnostics from what the schema says.
- codes
- The codes this crate’s reader and walker use.
- fix
- Applying fixes: text edits to the text, path edits to the tree.
- read
- Readers from text to a tree. Each reader is a module; JSON is the first.
- render
- The plain-text form of a report, written to be read by a person or a model as compiler output is: ASCII-safe framing, no color, no table.
- run
- One diagnosis from text to report, for a pack that brings the document kind’s schema, advisors and judge.
- schema
- A compiled JSON Schema, for the subset alpha2’s published schemas use. Any other keyword is refused with its place.
- shape
- The walker: every shape problem of a tree against a schema, at most one per value.
- suggest
- Close names: edit distance, one candidate or a short list.
- write
- A tree back to JSON text, and where each value went in it.
Structs§
- Code
- A kind of diagnostic: its stable name, severity, level and one sentence. Codes are the contract a consumer switches on; messages are not.
- Collector
- Collects diagnostics up to a capacity and counts the ones past it.
- Counts
- Counts by severity, grouped diagnostics counted by their places.
- Diagnostic
- One problem in a document.
- Entry
- One key and value of a map.
- Fix
- A way to fix a diagnostic: edits applied together.
- Node
- One value of a document and where it was read from.
- Number
- A number as it was spelt, so
1920.0and1920stay apart. - Options
- What a caller asks of a diagnosis, on every surface.
- Path
- A place in a document: a root name the document kind gives, then keys and indexes.
- Path
Error - Why a path could not be read.
- Reference
- A section of the schema reference: a topic and a definition, as
schema/reference/index.jsonnames them. - Report
- The answer for one document.
- Span
- A place in the text a node was read from.
Enums§
- Applicability
- Whether a fix may be applied by a program without asking.
- Edit
- One change to a document.
- Number
Kind - What a number’s spelling says about it.
- Segment
- One step of a path.
- Severity
- How serious a diagnostic is. Ordered from most to least serious.
- Value
- The kinds of value a document holds.
Constants§
- DEFAULT_
LIMIT - The most diagnostics a report answers unless asked otherwise.
- MAX_
ALSO - The most other places a grouped diagnostic lists.
- MAX_
EXCERPT_ BYTES - The most bytes of an excerpt.
- REPORT_
SCHEMA_ ID - Where the JSON Schema of a
Reportis published. - REVIEW_
PREFIX - The prefix of the codes a reviewer outside the engine uses for its findings.
Functions§
- excerpt
- The text of
span, cut at a character boundary toMAX_EXCERPT_BYTES. - group
- Merges diagnostics with one code, one message once indexes are removed and one path once
indexes are starred; the first keeps the others as
countandalso. - order
- Sorts by place in the text, errors before warnings at one place; diagnostics without a place keep their order after those with one.