feat: Multi-document YAML handling (spec v0.2.9-0)#20
Merged
dsillman2000 merged 5 commits intomainfrom Mar 26, 2026
Merged
Conversation
…ng. Copilot largely authored it.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds spec-compliant multi-document YAML handling to yaml-reference, extending reference resolution and root compilation semantics to properly distinguish multi-document streams from single-document sequences.
Changes:
- Introduces an internal
MultiDocumentwrapper and parses YAML viaload_all()to support multi-document inputs. - Updates
!referenceto error on multi-document targets while!reference-allexpands multi-doc files document-by-document (including per-document anchor extraction). - Adds/updates unit tests and documentation describing the new multi-document behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
yaml_reference/__init__.py |
Core multi-document parsing wrapper, updated resolution + post-processing pipeline to propagate multi-docs |
yaml_reference/cli.py |
Improves CLI error handling for compile failures |
tests/unit/test_reference.py |
Adds coverage for multi-doc behavior with !reference and !reference-all |
tests/unit/test_multidocument.py |
New tests for multi-document root compilation semantics |
tests/unit/test_flatten.py |
Adds coverage for !flatten interacting with multi-doc !reference-all |
tests/unit/test_merge.py |
Adds coverage for !merge interacting with multi-doc !reference-all |
README.md |
Documents new multi-document behavior and constraints |
.github/copilot-instructions.md |
Updates internal project documentation to reflect supported tags and pipeline stages |
You can also share your feedback on Copilot code review. Take the survey.
Ensure unit tests all still continue to pass. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brings project up-to-spec with: dsillman2000/yaml-reference-specs#32 (v0.2.9-0)
PR Summary
This branch adds explicit multi-document YAML support to yaml-reference.
!referencenow rejects multi-document target files with a clear error instead of implicitly treating them like normal YAML values.!reference-allnow expands multi-document files document-by-document, preserving file sort order and per-file document order, including anchor extraction from every document.!ignoredocuments dropped while!flattenand!mergecontinue to compose naturally with referenced multi-document content.Under the hood, the loader now uses an internal multi-document wrapper so it can distinguish a true multi-document file from a single YAML document whose root value happens to be a list.
The branch also adds focused unit coverage for multi-document
!reference,!reference-all, anchor extraction, flattening, merging, and root-file compilation, and updates the README to document the new behavior.