Skip to content

missing comments in yaml encoder #2456

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

Closed
sahroshan opened this issue Jun 24, 2023 · 2 comments
Closed

missing comments in yaml encoder #2456

sahroshan opened this issue Jun 24, 2023 · 2 comments

Comments

@sahroshan
Copy link

What version of CUE are you using (cue version)?

$ cue version
v0.5.0

Does this issue reproduce with the latest stable release?

yes

What did you do?

package main

import (
	"fmt"

	"cuelang.org/go/cue"
	"cuelang.org/go/cue/cuecontext"
	"cuelang.org/go/encoding/yaml"
)

const val = `
// will it appear in yaml
i: int | *123
`

func main() {
	var (
		c *cue.Context
		v cue.Value
	)

	// create a context
	c = cuecontext.New()

	// compile some CUE into a Value
	v = c.CompileString(val)
	yamlSkeleton, _ := yaml.Encode(v)
	fmt.Println(string(yamlSkeleton))
}

What did you expect to see?

# will it appear in yaml
i: 123

What did you see instead?

i: 123

I tried debugging the issue. Below are my findings.

we are converting converting cue.Value to ast.Node at

n := v.Syntax(cue.Final())
.

The ast.Node supports comment

ShowDocs: o.docs,
.

below changes fixes the issue.

FROM:

n := v.Syntax(cue.Final())

TO:

n := v.Syntax(cue.Final(), cue.Docs(true))
@sahroshan sahroshan added NeedsInvestigation Triage Requires triage/attention labels Jun 24, 2023
@mvdan
Copy link
Member

mvdan commented Jun 24, 2023

I believe this is a duplicate of #1180 :)

@mvdan
Copy link
Member

mvdan commented Jun 26, 2023

Closing for now.

@mvdan mvdan closed this as not planned Won't fix, can't repro, duplicate, stale Jun 26, 2023
@mvdan mvdan removed Triage Requires triage/attention NeedsInvestigation labels Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants