How kekavc24/yaml_dart works
This repository is a Dart monorepo for YAML tooling, split into two independently published packages: rookie_yaml for parsing/loading YAML, and dump_yaml for emitting YAML.
1. Top-level architecture
- The root README positions the repo as a YAML 1.2+ ecosystem.
- The two packages are complementary rather than layered in a single runtime pipeline: one turns YAML text into structured Dart data, the other turns structured Dart data or “dumpable” views back into YAML text.
2. rookie_yaml: input-to-model pipeline
- rookie_yaml is the parser/loader side.
- Its architecture is a classic staged pipeline: scanner → parser → document model → schema/loader.
- This separation is visible in the package structure and is the core boundary diagram for the repo.
3. Scanning layer
- lib/src/scanner handles low-level source traversal, character encoding, UTF handling, spans, and error reporting.
- This layer is responsible for turning raw text into position-aware tokens/events and for producing useful source-location diagnostics.
- It is the foundation for all higher-level parsing behavior.
4. Document parser
- lib/src/parser/document contains the YAML document grammar machinery.
- It has distinct handling for block nodes, flow nodes, scalars, directives, and parser state.
- This layer maps scanned input into a typed internal document representation, including YAML-specific features like block scalars, anchors/aliases, tags, and directives.
5. Schema and node model
- lib/src/schema defines the node abstractions used after parsing: YAML nodes, comments, scalar values, and schema rules.
- The document layer feeds this model, which then becomes the main contract for consumers and loaders.
- This boundary matters because it separates syntax recognition from semantic interpretation.
6. Resolver and loader behavior
- lib/src/parser/delegates, custom_resolvers.dart, and lib/src/loaders implement resolution and loading into Dart objects.
- The repo supports custom scalar resolvers, tag handling, and object loading, so YAML tags are not just parsed but can be mapped into application types.
- This is the semantic layer where YAML data becomes Dart values and objects.
7. YAML feature coverage in rookie_yaml
- The file layout shows support for anchors/aliases, directives, block and flow collections, quoted/plain scalars, custom tags, and node property inference.
- The included yaml_test_suite runner indicates conformance against upstream YAML test cases, so compatibility is a first-class architectural concern.
- That means the parser is designed around spec behavior, not just basic mapping/list parsing.
8. dump_yaml: model-to-output pipeline
- dump_yaml is the emitter side of the system.
- Its architecture starts from an event/tree representation and then chooses formatting strategies to produce YAML text.
- This package is about controllable serialization, not parsing.
9. Dump tree and formatting subsystems
- lib/src/event_tree builds an intermediate tree of nodes, scalar content, and visitors.
- lib/src/dumper contains the actual output strategies, with distinct block and inline/flow dumpers plus preamble handling.
- The split suggests a two-step design: normalize the input into a tree, then render that tree with style-aware rules.
10. Dump configuration and view layer
- lib/src/configs.dart and lib/src/views indicate the dumper supports configurable output and “dumpable” views of application objects.
- This is the repo’s key abstraction for serialization: callers can expose objects through a view contract instead of requiring direct YAML-specific types.
- That makes dump_yaml suitable for emitting structured application data, not just primitive maps/lists.
11. Testing strategy
- Both packages have extensive package-local tests, and rookie_yaml includes YAML test-suite integration.
- Tests are organized around language features: scalars, maps, sequences, block/flow collections, directives, tags, comments, recursion, and tree building.
- This reflects the architecture: each parser/dumper subsystem is validated independently.
12. Repository tooling and automation
- GitHub Actions handle routine tests, test reporting, coverage refresh, and bot/label automation.
- codecov.yml shows coverage is reported externally to Codecov.
- Scripts such as linear_merge.dart, package_filter.dart, and test_suite_comment.dart support CI and repo automation rather than runtime behavior.
13. How to draw the system boundary
- At a high level, treat the repo as two sibling packages under one monorepo:
- rookie_yaml: YAML text in → scanner/parser/schema/loader → Dart data or typed objects.
- dump_yaml: Dart data or dumpable views in → tree/dumper → YAML text out.
- Shared repo infrastructure (tests, GitHub Actions, coverage, publishing metadata) surrounds both packages but does not participate in the runtime data flow.
Main entry points: document_parser.dart Document parser · document_test.dart Parser tests · routine-tests.yaml GitHub Actions · source_iterator.dart Scanner
Components 18
Repo infra
Monorepo metadata, CI, and automation around both packages.
- YAML ecosystem · Top-level monorepo framing for YAML 1.2+ tooling.
README.md - GitHub Actions · Workflows and custom actions for testing, coverage, and bot automation.
.github/workflows/routine-tests.yaml - Repo scripts · Helper scripts for merge automation, package filtering, and test-suite comments.
scripts/linear_merge.dart
rookie_yaml
YAML text input pipeline: scan, parse, schema, and load.
- rookie_yaml API · Public facade for parsing, loading, and schema-backed YAML input handling.
packages/rookie_yaml/lib/rookie_yaml.dart - Scanner · Character traversal, encoding, spans, and source-location error reporting.
packages/rookie_yaml/lib/src/scanner/source_iterator.dart - Document parser · Document parsing and parser state for block/flow nodes, scalars, directives, anchors, and tags.
packages/rookie_yaml/lib/src/parser/document/document_parser.dart - Delegates · Pluggable node, map-like, sequence-like, and scalar delegation during parsing.
packages/rookie_yaml/lib/src/parser/delegates/node_delegate.dart - Directives & tags · YAML directives, tag handles, tag forms, and resolver tag parsing.
packages/rookie_yaml/lib/src/parser/directives/directives.dart - Schema model · YAML nodes, comments, scalar values, and schema rules exposed after parsing.
packages/rookie_yaml/lib/src/schema/schema.dart - Loaders · Resolution and loading of parsed YAML into Dart values and typed objects.
packages/rookie_yaml/lib/src/loaders/loader.dart - Custom resolvers · Custom scalar resolvers and parser-side resolution hooks for application types.
packages/rookie_yaml/lib/src/parser/custom_resolvers.dart
dump_yaml
YAML output pipeline: tree building, formatting, and views.
- dump_yaml API · Public facade for configurable YAML emission and dumpable views.
packages/dump_yaml/lib/dump_yaml.dart - Event tree · Normalized tree of nodes, scalar content, and visitor traversal for dumping.
packages/dump_yaml/lib/src/event_tree/tree_builder.dart - Dumper · Block, inline/flow, and preamble formatting strategies that render YAML text.
packages/dump_yaml/lib/src/dumper/yaml_dumper.dart - Views · Dumpable view contracts used to expose application objects to the emitter.
packages/dump_yaml/lib/src/views/views.dart
Validation
Package tests and YAML test-suite conformance harnesses.
- Parser tests · Feature-focused tests for parsing, loading, node properties, tags, and YAML conformance.
packages/rookie_yaml/test/document_test.dart - YAML test-suite · Runner and reporter for upstream YAML test-suite compatibility checks.
packages/rookie_yaml/test/yaml_test_suite/runner.dart - Emitter tests · Tests for tree building, maps, lists, scalars, comments, recursion, and unfolding behavior.
packages/dump_yaml/test/tree_builder_test.dart
Connections 21
- YAML ecosystem → rookie_yaml API: describes · Documents the input-side package and its YAML parsing/loading role.
- YAML ecosystem → dump_yaml API: describes · Documents the output-side package and its YAML emission role.
- GitHub Actions → Parser tests: runs · Automates package validation and routine test execution.
- GitHub Actions → Emitter tests: runs · Automates package validation and routine test execution.
- Repo scripts → GitHub Actions: supports · Provides repository automation used by workflows and bot actions.
- rookie_yaml API → Scanner: starts with · Public API builds on source scanning and tokenization.
- Scanner → Document parser: feeds · Scanned input becomes the parser's document grammar input.
- Document parser → Delegates: uses · Parser delegates handle specialized node and collection behaviors.
- Document parser → Directives & tags: interprets · Document parsing resolves directives and tag forms.
- Document parser → Schema model: produces · Parsed documents are materialized into schema-backed nodes.
- Custom resolvers → Loaders: extends · Custom resolution influences how parsed values become Dart objects.
- Schema model → Loaders: consumed by · Schema nodes are the contract passed into loading and object mapping.
- Parser tests → Scanner: verifies · Exercises lexical correctness and diagnostics.
- Parser tests → Document parser: verifies · Exercises document grammar, scalars, directives, and collections.
- Parser tests → Loaders: verifies · Exercises YAML-to-Dart loading and type inference.
- YAML test-suite → Document parser: conforms · Checks parser behavior against upstream YAML cases.
- dump_yaml API → Views: accepts · Public API uses dumpable views as the object-facing abstraction.
- Views → Event tree: normalizes into · Views and source objects are shaped into an intermediate event tree.
- Event tree → Dumper: renders via · Tree nodes are formatted by dumper strategies into YAML text.
- Dumper → Emitter tests: verified by · Emitter behavior is exercised by package-local tests.
- Emitter tests → Event tree: covers · Tests validate normalization and tree-building behavior.