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!
```
##
## Head comment with document split
Given a sample.yml file of:
```yaml
# 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
Given a sample.yml file of:
@ -14,13 +17,15 @@ will output
nested: cat
```
## Show parent
## Parent of nested matches
Given a sample.yml file of:
```yaml
a:
fruit: apple
name: bob
b:
fruit: banana
name: sam
```
then
```bash
@ -29,6 +34,7 @@ yq eval '.. | select(. == "banana") | parent' sample.yml
will output
```yaml
fruit: banana
name: sam
```
## No parent

View File

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

View File

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