zizmor/crates/yamlpatch
William Woodruff 2942f11dc2
Some checks are pending
CodSpeed Benchmarks / Run benchmarks (push) Waiting to run
CI / Lint (push) Waiting to run
CI / Test (push) Waiting to run
CI / Test site build (push) Waiting to run
CI / All tests pass (push) Blocked by required conditions
zizmor wheel builds for PyPI 🐍 / Build Linux wheels (manylinux) (push) Waiting to run
zizmor wheel builds for PyPI 🐍 / Build Linux wheels (musllinux) (push) Waiting to run
zizmor wheel builds for PyPI 🐍 / Build Windows wheels (push) Waiting to run
zizmor wheel builds for PyPI 🐍 / Build macOS wheels (push) Waiting to run
zizmor wheel builds for PyPI 🐍 / Build source distribution (push) Waiting to run
zizmor wheel builds for PyPI 🐍 / Release (push) Blocked by required conditions
Deploy zizmor documentation site 🌐 / Deploy zizmor documentation to GitHub Pages 🌐 (push) Waiting to run
GitHub Actions Security Analysis with zizmor 🌈 / Run zizmor 🌈 (push) Waiting to run
Bump all tree-sitter dependent crates (#1457)
Avoids dep hell.

Signed-off-by: William Woodruff <william@yossarian.net>
2025-12-18 22:36:14 +00:00
..
src Support adding block sequence in yamlpatch (#1364) 2025-11-28 10:27:34 -05:00
tests chore(deps): bump the cargo group across 1 directory with 12 updates (#1430) 2025-12-10 22:54:31 -08:00
Cargo.toml Bump all tree-sitter dependent crates (#1457) 2025-12-18 22:36:14 +00:00
LICENSE Extract yamlpatch into a support crate (#1001) 2025-07-02 19:35:48 -04:00
README.md Update README (#1389) 2025-11-29 18:52:14 +00:00

yamlpatch

zizmor CI Crates.io docs.rs GitHub Sponsors Discord

Comment and format-preserving YAML patch operations.

yamlpatch builds on yamlpath to provide surgical modification capabilities while preserving comments, formatting, and structure.

Important

This is not a substitute for comprehensive YAML processing libraries. It's designed for targeted modifications that preserve the original document's formatting and comments.

Why?

When working with YAML configuration files, it's often necessary to make programmatic changes while preserving the human-readable aspects of the file: comments, formatting, indentation, and style choices.

Traditional YAML processing involves parsing to a document model, making changes, and re-serializing. This approach destroys the original formatting and comments, making the result less suitable for version control and human review.

yamlpatch solves this by providing targeted patch operations that:

  • Preserve comments and their positioning
  • Maintain original indentation and formatting
  • Respect different YAML styles (block vs. flow, single vs. multi-line)
  • Support precise fragment rewriting within string values
  • Handle complex nested structures gracefully

Operations

yamlpatch supports the following patch operations:

  • Replace: Replace a value at a specific path
  • Add: Add new key-value pairs to mappings
  • Remove: Remove keys or elements
  • MergeInto: Merge values into existing mappings
  • Append: Append items to block sequences
  • ReplaceComment: Replace comments associated with features
  • RewriteFragment: Rewrite portions of string values (useful for templating)

Each operation preserves the document's formatting and structure (as best-effort).

License

MIT License.