Skip to content

Commit ea8d438

Browse files
doc: add stopBy/field reference
1 parent 41edce2 commit ea8d438

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

website/reference/rule.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,35 @@ follows:
198198
stopBy: end # stopBy accepts 'end', 'neighbor' or another rule object.
199199
```
200200

201+
-----
202+
203+
There are two additional fields in relational rules:
204+
205+
#### `stopBy`
206+
* type: `"neighbor"` or `"end"` or `Rule` object
207+
* default: `"neighbor"`
208+
209+
`stopBy` is an option to control how the search should stop when looking for the target node.
210+
211+
It can have three types of value:
212+
213+
* `"neighbor"`: stop when the target node's immediate surrounding node does not match the relational rule. This is the default behavior.
214+
* `"end"`: search all the way to the end of the search direction. i.e. to the root node for `inside`, to the leaf node for `has`, to the first sibling for `follows`, and to the last sibling for `precedes`.
215+
* `Rule` object: stop when the target node's surrounding node does match the rule. `stopBy` is inclusive. If the matching surrounding node also match the relational rule, the target node is still considered as matched.
216+
217+
#### `field`
218+
* type: `String`
219+
* required: No
220+
* Only available in `inside` and `has` relational rules
221+
222+
`field` is an option to specify the sub-node in the target node to match the relational rule.
223+
224+
Note `field` and `kind` are two different concepts.
225+
201226
:::tip
202227
Only relational rules have `stopBy` and `field` options.
203228
:::
204229

205-
206230
## Composite Rules
207231

208232
### `all`

0 commit comments

Comments
 (0)