dtolnay / serde-yaml

Strongly typed YAML library for Rust
Apache License 2.0
965 stars 164 forks source link

Preservation of comments #219

Closed simonsan closed 3 years ago

simonsan commented 3 years ago

I'm dealing with a file that has some information annotated within comments. Are there any plans to add preservation of comments to serde_yaml?

Thank you for the nice library!

P.S.: If someone searches for an immediate solution before this is implemented use ruamel for Python. https://pypi.org/project/ruamel.yaml/

simonsan commented 3 years ago

Tracking Issue: https://github.com/chyh1990/yaml-rust/issues/146

PR that brings (half of) the feature: https://github.com/chyh1990/yaml-rust/pull/181

dtolnay commented 3 years ago

I would prefer not to build this into this crate. I don't know of a YAML library for Rust that is designed for preserving comments but for TOML there is tomllib — you may need to look at how they do it and build a YAML library based on their approach.