mirror of
https://github.com/mikefarah/yq.git
synced 2024-12-19 20:19:04 +00:00
Fixing comments
This commit is contained in:
parent
c2808dc6c1
commit
7e09a66b0b
@ -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!
|
||||||
|
3
pkg/yqlib/doc/headers/parent.md
Normal file
3
pkg/yqlib/doc/headers/parent.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Parent
|
||||||
|
|
||||||
|
Parent simply returns the parent nodes of the matching nodes.
|
@ -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
|
||||||
|
@ -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`,
|
||||||
|
@ -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",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user