Fixing comments

This commit is contained in:
Mike Farah 2021-11-24 10:59:19 +11:00
parent c2808dc6c1
commit 7e09a66b0b
5 changed files with 15 additions and 6 deletions

View File

@ -139,7 +139,7 @@ will output
welcome! welcome!
``` ```
## ## Head comment with document split
Given a sample.yml file of: Given a sample.yml file of:
```yaml ```yaml
# welcome! # welcome!

View File

@ -0,0 +1,3 @@
# Parent
Parent simply returns the parent nodes of the matching nodes.

View File

@ -1,3 +1,6 @@
# Parent
Parent simply returns the parent nodes of the matching nodes.
## Simple example ## Simple example
Given a sample.yml file of: Given a sample.yml file of:
@ -14,13 +17,15 @@ will output
nested: cat nested: cat
``` ```
## Show parent ## Parent of nested matches
Given a sample.yml file of: Given a sample.yml file of:
```yaml ```yaml
a: a:
fruit: apple fruit: apple
name: bob
b: b:
fruit: banana fruit: banana
name: sam
``` ```
then then
```bash ```bash
@ -29,6 +34,7 @@ yq eval '.. | select(. == "banana") | parent' sample.yml
will output will output
```yaml ```yaml
fruit: banana fruit: banana
name: sam
``` ```
## No parent ## No parent

View File

@ -113,7 +113,7 @@ var commentOperatorScenarios = []expressionScenario{
}, },
}, },
{ {
skipDoc: false, description: "Head comment with document split",
dontFormatInputForDoc: true, dontFormatInputForDoc: true,
document: "# welcome!\n---\n# bob\na: cat # meow\n\n# have a great day", document: "# welcome!\n---\n# bob\na: cat # meow\n\n# have a great day",
expression: `headComment`, expression: `headComment`,

View File

@ -14,11 +14,11 @@ var parentOperatorScenarios = []expressionScenario{
}, },
}, },
{ {
description: "Show parent", description: "Parent of nested matches",
document: `{a: {fruit: apple}, b: {fruit: banana}}`, document: `{a: {fruit: apple, name: bob}, b: {fruit: banana, name: sam}}`,
expression: `.. | select(. == "banana") | parent`, expression: `.. | select(. == "banana") | parent`,
expected: []string{ expected: []string{
"D0, P[b], (!!map)::{fruit: banana}\n", "D0, P[b], (!!map)::{fruit: banana, name: sam}\n",
}, },
}, },
{ {