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!
|
||||
```
|
||||
|
||||
##
|
||||
## Head comment with document split
|
||||
Given a sample.yml file of:
|
||||
```yaml
|
||||
# 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
|
||||
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
|
||||
|
@ -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`,
|
||||
|
@ -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",
|
||||
},
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user