Expand description
tramlines-core: the part of tramlines that every format of document shares.
The core grammar, the vocabulary a schema is written in, and the
layers a format grammar and a host extension add to it; the shapes,
types and formats a rule matches text with; the frontmatter and the
lifecycle of a document; and the Finding a failure is reported as.
A format crate, such as tramlines-md, adds what its documents hold.
A host program uses a format crate, which re-exports what it needs from here. This crate alone reads a formats file and matches lines against its formats:
use tramlines_core::grammar::{FormatMatch, FormatRegistry, RegexCache, load_core_grammar};
let grammar = load_core_grammar()?;
let formats = "registry:\n item:\n template: '${name:word} x${n:int}'\n example: Milk x2\n";
let registry = FormatRegistry::from_text(formats, &[], &grammar, &RegexCache::new())?;
let item = registry.get("item").expect("the file defines `item`");
assert!(matches!(item.check("Bread x1"), FormatMatch::Ok(_)));
assert!(matches!(item.check("Bread"), FormatMatch::Fail(_)));Re-exports§
Modules§
- frontmatter
- Frontmatter constraints, lifecycle keys and the id template, checked
the same way in every format. The check reports
Events, which the checker of a format records with what it knows of where it is. - grammar
- The core grammar and the layers on it, schema validation, the lowering of the keys every format shares, the format registry, and id templates.
- text
- Checks of a scalar value that every format shares, and the English that a finding is written in: the article before a word and a count.
- yaml
- YAML 1.2 core-schema parsing as TL_13 and TL_14 read it.
Structs§
- Finding
- One line of the report.
- Locator
- Where in a schema the rule that failed sits: the
idof the schema, and the rule’srule-id, else its section and block position. A finding that a schema rule raises ends with it. - Problem
- A failure found before the file it is on is known: the criterion it breaks, and what failed.
- Repo
Path - A path relative to the repository root, which starts with
/and uses forward slashes. The path/is the root itself. - Repo
Root - The repository root on disk.
Enums§
Type Aliases§
- Result
- Convenience alias for results from this crate.