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

cmd/export: emit comments by default for yaml #1549

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions cmd/cue/cmd/testdata/script/export_yaml_comments.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cue export --out yaml ./hello
cmp stdout expect-stdout
-- expect-stdout --
# cloud-config
foo: bar
hello:
# occupy
world: from mars?
-- hello/hello.cue --
package hello

//cloud-config
foo: "bar"

hello: {
// occupy
world: "from mars?"
}
2 changes: 1 addition & 1 deletion cue/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2139,7 +2139,7 @@ func All() Option {

// Docs indicates whether docs should be included.
func Docs(include bool) Option {
return func(p *options) { p.docs = true }
return func(p *options) { p.docs = include }
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: unrelated fix for a problem I noticed

}

// Definitions indicates whether definitions should be included.
Expand Down
4 changes: 2 additions & 2 deletions pkg/encoding/yaml/manual.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func Marshal(v cue.Value) (string, error) {
// messages can be passed.
return "", internal.ErrIncomplete
}
n := v.Syntax(cue.Final(), cue.Concrete(true))
n := v.Syntax(cue.Final(), cue.Concrete(true), cue.Docs(true))
b, err := cueyaml.Encode(n)
return string(b), err
}
Expand All @@ -53,7 +53,7 @@ func MarshalStream(v cue.Value) (string, error) {
buf.WriteString("---\n")
}
v := iter.Value()
if err := v.Validate(cue.Concrete(true)); err != nil {
if err := v.Validate(cue.Concrete(true), cue.Docs(true)); err != nil {
if err := v.Validate(); err != nil {
return "", err
}
Expand Down