Why
ConvertFrom-Yaml discards all comments during parsing, and ConvertTo-Yaml has no concept of comments to emit, so a round-trip ConvertFrom-Yaml | ConvertTo-Yaml loses every # comment even though the YAML 1.2.2 spec treats comments as a valid presentation detail. A user editing a config file through this module should not have inline documentation silently deleted.
What
Preserve comments across a full round-trip:
$yaml | ConvertFrom-Yaml | ConvertTo-Yaml # comments survive
This covers leading comments above a node, trailing comments on the same line as a key/value, and standalone comments between unrelated nodes.
Acceptance criteria
- A YAML file with a representative mix of comment kinds round-trips through
ConvertFrom-Yaml | ConvertTo-Yaml byte-equivalent (or content-equivalent ignoring whitespace normalisation)
- Default behavior unchanged when comment preservation is not requested
- Spec test 2.9 (Single Document with Two Comments) passes a round-trip assertion
Related
Why
ConvertFrom-Yamldiscards all comments during parsing, andConvertTo-Yamlhas no concept of comments to emit, so a round-tripConvertFrom-Yaml | ConvertTo-Yamlloses every#comment even though the YAML 1.2.2 spec treats comments as a valid presentation detail. A user editing a config file through this module should not have inline documentation silently deleted.What
Preserve comments across a full round-trip:
This covers leading comments above a node, trailing comments on the same line as a key/value, and standalone comments between unrelated nodes.
Acceptance criteria
ConvertFrom-Yaml | ConvertTo-Yamlbyte-equivalent (or content-equivalent ignoring whitespace normalisation)Related