zizmor/crates/yamlpatch
William Woodruff 0737eadf45
Some checks failed
GitHub Actions Security Analysis with zizmor 🌈 / Run zizmor 🌈 (push) Has been cancelled
CI / Lint (push) Has been cancelled
zizmor wheel builds for PyPI 🐍 / Build Linux wheels (manylinux) (push) Has been cancelled
zizmor wheel builds for PyPI 🐍 / Build Linux wheels (musllinux) (push) Has been cancelled
Benchmark baseline / Continuous Benchmarking with Bencher (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Test site build (push) Has been cancelled
zizmor wheel builds for PyPI 🐍 / Build Windows wheels (push) Has been cancelled
zizmor wheel builds for PyPI 🐍 / Build macOS wheels (push) Has been cancelled
zizmor wheel builds for PyPI 🐍 / Build source distribution (push) Has been cancelled
Deploy zizmor documentation site 🌐 / Deploy zizmor documentation to GitHub Pages 🌐 (push) Has been cancelled
CI / All tests pass (push) Has been cancelled
zizmor wheel builds for PyPI 🐍 / Release (push) Has been cancelled
chore: bump yamlpatch minor to 0.4.0 (#1283)
2025-10-23 21:39:02 -04:00
..
src chore: prep release v1.12.1 (#1083) 2025-08-15 00:27:09 -04:00
tests Add Fix for known-vulnerable-actions audit rule (#1019) 2025-07-20 21:08:14 -04:00
Cargo.toml chore: bump yamlpatch minor to 0.4.0 (#1283) 2025-10-23 21:39:02 -04:00
LICENSE Extract yamlpatch into a support crate (#1001) 2025-07-02 19:35:48 -04:00
README.md refactor: add subfeature crate (#1030) 2025-07-17 02:08:29 +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 several types of 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
  • RewriteFragment: Rewrite portions of string values (useful for templating)

Each operation is designed to work with the existing document structure and formatting, making minimal changes while achieving the desired result.

License

MIT License.