diff --git a/pkg/yqlib/doc/operators/add.md b/pkg/yqlib/doc/operators/add.md index 469e13d8..4e3e6f53 100644 --- a/pkg/yqlib/doc/operators/add.md +++ b/pkg/yqlib/doc/operators/add.md @@ -232,7 +232,7 @@ yq '.a += "3h10m"' sample.yml ``` will output ```yaml -a: 2021-01-01T03:10:00Z +a: 2021-01-01T00:00:00Z3h10m ``` ## Date addition - custom format diff --git a/pkg/yqlib/doc/operators/anchor-and-alias-operators.md b/pkg/yqlib/doc/operators/anchor-and-alias-operators.md index 14b0bef2..c120cdb1 100644 --- a/pkg/yqlib/doc/operators/anchor-and-alias-operators.md +++ b/pkg/yqlib/doc/operators/anchor-and-alias-operators.md @@ -248,12 +248,6 @@ then yq 'explode(.f)' sample.yml ``` will output -```yaml -f: - a: cat - cat: b -``` - ## Explode with merge anchors Given a sample.yml file of: ```yaml diff --git a/pkg/yqlib/doc/operators/comment-operators.md b/pkg/yqlib/doc/operators/comment-operators.md index 414fff83..d9bc8bd5 100644 --- a/pkg/yqlib/doc/operators/comment-operators.md +++ b/pkg/yqlib/doc/operators/comment-operators.md @@ -152,7 +152,7 @@ will output fc: "" - p: name.0 isKey: false - hc: under-name-comment + hc: "" lc: "" fc: "" ``` @@ -172,7 +172,7 @@ yq '.name[0] | headComment' sample.yml ``` will output ```yaml -under-name-comment + ``` ## Set head comment @@ -258,7 +258,7 @@ yq '... comments=""' sample.yml will output ```yaml a: cat -b: +b: null ``` ## Get line comment @@ -293,7 +293,6 @@ yq '. | head_comment' sample.yml ``` will output ```yaml -welcome! ``` @@ -313,8 +312,7 @@ yq 'head_comment' sample.yml ``` will output ```yaml -welcome! -bob + ``` ## Get foot comment @@ -333,7 +331,6 @@ yq '. | foot_comment' sample.yml ``` will output ```yaml -have a great day -no really + ``` diff --git a/pkg/yqlib/doc/operators/datetime.md b/pkg/yqlib/doc/operators/datetime.md index 685618fc..4b6ca4f7 100644 --- a/pkg/yqlib/doc/operators/datetime.md +++ b/pkg/yqlib/doc/operators/datetime.md @@ -170,7 +170,7 @@ yq '.a += "3h10m"' sample.yml ``` will output ```yaml -a: 2021-01-01T03:10:00Z +a: 2021-01-01T00:00:00Z3h10m ``` ## Date subtraction @@ -185,10 +185,6 @@ then yq '.a -= "3h10m"' sample.yml ``` will output -```yaml -a: 2021-01-01T00:00:00Z -``` - ## Date addition - custom format Given a sample.yml file of: ```yaml diff --git a/pkg/yqlib/doc/operators/keys.md b/pkg/yqlib/doc/operators/keys.md index 4dec429b..3576a57e 100644 --- a/pkg/yqlib/doc/operators/keys.md +++ b/pkg/yqlib/doc/operators/keys.md @@ -109,7 +109,7 @@ yq '.a.x | key | headComment' sample.yml ``` will output ```yaml -comment on key + ``` ## Check node is a key diff --git a/pkg/yqlib/doc/operators/subtract.md b/pkg/yqlib/doc/operators/subtract.md index 902a3a14..355e546b 100644 --- a/pkg/yqlib/doc/operators/subtract.md +++ b/pkg/yqlib/doc/operators/subtract.md @@ -105,10 +105,6 @@ then yq '.a -= "3h10m"' sample.yml ``` will output -```yaml -a: 2021-01-01T00:00:00Z -``` - ## Date subtraction - custom format Use with_dtf to specify your datetime format. See [date-time operators](https://mikefarah.gitbook.io/yq/operators/date-time-operators) for more information. diff --git a/pkg/yqlib/goccy_yaml_test.go b/pkg/yqlib/goccy_yaml_test.go index 8389e913..4b31e39c 100644 --- a/pkg/yqlib/goccy_yaml_test.go +++ b/pkg/yqlib/goccy_yaml_test.go @@ -55,30 +55,30 @@ var goccyYamlFormatScenarios = []formatScenario{ // input: "[3]", // expected: "[3]\n", // }, - // { - // description: "basic - plain string", - // skipDoc: true, - // input: `a: meow`, - // expected: "a: meow\n", - // }, - // { - // description: "basic - double quoted string", - // skipDoc: true, - // input: `a: "meow"`, - // expected: "a: \"meow\"\n", - // }, - // { - // description: "basic - single quoted string", - // skipDoc: true, - // input: `a: 'meow'`, - // expected: "a: 'meow'\n", - // }, - // { - // description: "basic - string block", - // skipDoc: true, - // input: "a: |\n meow\n", - // expected: "a: |\n meow\n", - // }, + { + description: "basic - plain string", + skipDoc: true, + input: `a: meow`, + expected: "a: meow\n", + }, + { + description: "basic - double quoted string", + skipDoc: true, + input: `a: "meow"`, + expected: "a: \"meow\"\n", + }, + { + description: "basic - single quoted string", + skipDoc: true, + input: `a: 'meow'`, + expected: "a: 'meow'\n", + }, + { + description: "basic - string block", + skipDoc: true, + input: "a: |\n meow\n", + expected: "a: |\n meow\n", + }, // { // description: "basic - long string", // skipDoc: true, diff --git a/pkg/yqlib/single_test.go b/pkg/yqlib/single_test.go new file mode 100644 index 00000000..4a3b831f --- /dev/null +++ b/pkg/yqlib/single_test.go @@ -0,0 +1,15 @@ +package yqlib + +// func TestSingScenarioForDebugging(t *testing.T) { +// logging.SetLevel(logging.DEBUG, "") +// testScenario(t, &expressionScenario{ +// description: "Dont explode alias and anchor - check alias parent", +// skipDoc: true, +// document: `{a: &a [1], b: *a}`, +// expression: `.b[0]`, +// expected: []string{ +// "D0, P[a 0], (!!int)::1\n", +// }, +// }) +// logging.SetLevel(logging.ERROR, "") +// }