ruby / ruby/psych

Add enough primitives to support comment preservation

Open
#566 5 comments 13 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
597
Forks
223
Avg merge
11h 23m
Merged PRs (30d)
3

Description

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing Psych's existing parser primitives and its libyaml integration, then compare the comment-preservation approach described with ruamel.yaml. The issue is exploratory and does not name files, tests, or a concrete acceptance criterion; a decided design and defined completion criteria are needed before implementation can begin.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, ruby
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.