Skip to content

Commit 23060cb

Browse files
committed
Improving first op docs
1 parent 4532346 commit 23060cb

File tree

2 files changed

+10
-47
lines changed

2 files changed

+10
-47
lines changed

pkg/yqlib/doc/operators/first.md

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ will output
273273
100
274274
```
275275

276-
## First element with no RHS from array
276+
## First element with no filter from array
277277
Given a sample.yml file of:
278278
```yaml
279279
- 10
@@ -289,7 +289,7 @@ will output
289289
10
290290
```
291291

292-
## First element with no RHS from array of maps
292+
## First element with no filter from array of maps
293293
Given a sample.yml file of:
294294
```yaml
295295
- a: 10
@@ -304,42 +304,3 @@ will output
304304
a: 10
305305
```
306306
307-
## No RHS on empty array returns nothing
308-
Given a sample.yml file of:
309-
```yaml
310-
[]
311-
```
312-
then
313-
```bash
314-
yq 'first' sample.yml
315-
```
316-
will output
317-
```yaml
318-
```
319-
320-
## No RHS on scalar returns nothing
321-
Given a sample.yml file of:
322-
```yaml
323-
hello
324-
```
325-
then
326-
```bash
327-
yq 'first' sample.yml
328-
```
329-
will output
330-
```yaml
331-
```
332-
333-
## No RHS on null returns nothing
334-
Given a sample.yml file of:
335-
```yaml
336-
null
337-
```
338-
then
339-
```bash
340-
yq 'first' sample.yml
341-
```
342-
will output
343-
```yaml
344-
```
345-

pkg/yqlib/operator_first_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,37 +139,39 @@ var firstOperatorScenarios = []expressionScenario{
139139
"D0, P[1], (!!int)::100\n",
140140
},
141141
},
142-
// New tests for no RHS (return first child)
143142
{
144-
description: "First element with no RHS from array",
143+
description: "First element with no filter from array",
145144
document: "[10, 100, 1]",
146145
expression: `first`,
147146
expected: []string{
148147
"D0, P[0], (!!int)::10\n",
149148
},
150149
},
151150
{
152-
description: "First element with no RHS from array of maps",
151+
description: "First element with no filter from array of maps",
153152
document: "[{a: 10},{a: 100}]",
154153
expression: `first`,
155154
expected: []string{
156155
"D0, P[0], (!!map)::{a: 10}\n",
157156
},
158157
},
159158
{
160-
description: "No RHS on empty array returns nothing",
159+
description: "No filter on empty array returns nothing",
160+
skipDoc: true,
161161
document: "[]",
162162
expression: `first`,
163163
expected: []string{},
164164
},
165165
{
166-
description: "No RHS on scalar returns nothing",
166+
description: "No filter on scalar returns nothing",
167+
skipDoc: true,
167168
document: "hello",
168169
expression: `first`,
169170
expected: []string{},
170171
},
171172
{
172-
description: "No RHS on null returns nothing",
173+
description: "No filter on null returns nothing",
174+
skipDoc: true,
173175
document: "null",
174176
expression: `first`,
175177
expected: []string{},

0 commit comments

Comments
 (0)