psych icon indicating copy to clipboard operation
psych copied to clipboard

Add enough primitives to support comment preservation

Open SamSaffron opened this issue 3 years ago • 1 comments

Preserving comments in YAML files is a general problem many automation tools have.

The general problem is that you have some YAML file say:

# the answer
- universe: 41

When you decide to programmatically change the file to correct the answer by loading and saving YAML you end up stripping comments

- universe: 42

There are 2 current families of solutions in the wild. The first is regex hacking. The second is leaning on https://pypi.org/project/ruamel.yaml/.

Was wondering if having enough internal primitives in psych to implement this is a good idea? Should comment preservation be built into Psych (optionally) or is this the role of some other gem that consumes it?

SamSaffron avatar Jul 19 '22 04:07 SamSaffron