saphyr-rs / saphyr

A set of crates dedicated to parsing YAML.
58 stars 5 forks source link

Support for comments #12

Open Weasy666 opened 1 month ago

Weasy666 commented 1 month ago

Right now, comments are lost when deserializing a YAML file. Would you consider adding comment support to this library?

There is a open issue for this in yaml-rust: https://github.com/chyh1990/yaml-rust/issues/146 And even a pull request which implements half of it: https://github.com/chyh1990/yaml-rust/pull/181

zevisert commented 4 days ago

Popping in since I'm shopping around for a yaml crate for a project right now. Comment support is (IMV) a very important feature for a library like this, as anyone building a tool which needs to update (formatters, linters, configuration updaters, etc) a yaml document will probably want their tool to be a no-op if nothing needs to be changed.

Consider a formatter, if, say, indentation and flow styles already meet the desired format, the formatter should certainly not strip comments! It may also be useful to inform the formatter about content in the file, with directives either at the top of the file, or on specific lines

Ethiraric commented 11 hours ago

Comments will come one day. This will have to be addressed in the parser first.

Regarding the formatter, there's a lot more to be done here to write one with saphyr. For instance, we currently do not extract whether collections use flow style or the style of scalar that was used (fold, literal, plain, ...).