Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve strategy for comment output #1629

Open
rogpeppe opened this issue Apr 13, 2022 · 0 comments
Open

improve strategy for comment output #1629

rogpeppe opened this issue Apr 13, 2022 · 0 comments
Labels
NeedsDesign Functionality seems desirable, but not sure how it should look like.

Comments

@rogpeppe
Copy link
Member

There are a number of open issues regarding comments:

Most of these are to do with comment formatting, but there's a deeper issue here: what should happen to comments when we apply unification to CUE values?

Here's a simple example to illustrate current behaviour:

// Comment 1
a: 1

// Comment 2
a: 1

// Comment 3
a: 1

Running cue def on that results in the following output:

// Comment 1

// Comment 2

// Comment 3
a: 1

Running cue def again gives:

	// Comment 3
a: 1

This isn't great for a few reasons:

  • cue def should probably produce output that doesn't change when run through cue def again.
  • The result is dependent on the order of unification. If the three parts are in three separate files, the order of the comments depends on the file names.
  • comments are lost the second time cue def is run

There's no obvious "right answer" here. Some possibilities:

  1. Don't output comments at all.
  2. Keep a single comment only; any additional comments cause the comment to disappear
  3. Retain all comments, concatenating comment text from all unifications, sorting by comment text.
  4. Provide a way to customize whether a comment is included or not.

Choice 1 is obviously the easiest option, but comments are very useful and if possible it would be good to better than that.

Choice 2 makes for unstable output. If someone adds a comment to a schema, it could cause an important comment on the data to disappear.

Choice 3 results in comments that are a mishmash from different layers in non-obvious order. It's not clear that we actually want all comments anyway. Consider this example. That workflow schema has copious comments that describe how to use the schema, but those aren't very useful on the final result, where we'd prefer to see comments about the final rendered workflow rather than the schema.

Choice 4 could potentially provide the best of both worlds, but leaves open the question of how that customization might work.

@rogpeppe rogpeppe added NeedsInvestigation Triage Requires triage/attention NeedsDesign Functionality seems desirable, but not sure how it should look like. and removed NeedsInvestigation Triage Requires triage/attention labels Apr 13, 2022
@myitcv myitcv added the zGarden label Jun 13, 2023
@mvdan mvdan removed the zGarden label Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsDesign Functionality seems desirable, but not sure how it should look like.
Projects
None yet
Development

No branches or pull requests

3 participants