Skip to content

Commit

Permalink
chore: update example log
Browse files Browse the repository at this point in the history
  • Loading branch information
zyyv authored and HerringtonDarkholme committed Oct 22, 2024
1 parent 8a5480e commit ff23512
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions website/guide/api-usage/js-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ arg.text() // returns 'hello'
node.getMultipleMatches('A')
const logs = root.find('logger($$$ARGS)')
// returns [SgNode('hello'), SgNode('world'), SgNode('!')]
node.getMultipleMatches("ARGS")
node.getMatch("A") // returns null
// returns [SgNode('hello'), SgNode(','), SgNode('world'), SgNode(','), SgNode('!')]
logs.getMultipleMatches("ARGS")
logs.getMatch("A") // returns null
```

## Inspection
Expand Down Expand Up @@ -303,4 +303,4 @@ import { parse, Lang } from '@ast-grep/napi'
const sg = parse(Lang.Python, 'def test(): pass')

console.log(sg.root().has('function_definition'))
```
```
10 changes: 5 additions & 5 deletions website/guide/api-usage/py-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ arg.text() # returns 'hello'
# returns [] because $A and $$$A are different
node.get_multiple_matches("A")
node = root.find(pattern="logger($$$ARGS)")
# returns [SgNode('hello'), SgNode('world'), SgNode('!')]
node.get_multiple_matches("ARGS")
node.get_match("A") # returns None
logs = root.find(pattern="logger($$$ARGS)")
# returns [SgNode('hello'), SgNode(','), SgNode('world'), SgNode(','), SgNode('!')]
logs.get_multiple_matches("ARGS")
logs.get_match("A") # returns None
```

`SgNode` also supports `__getitem__` to get the match of single meta variable.
Expand Down Expand Up @@ -313,4 +313,4 @@ Note, `logger.log($A)` will not generate `logger.log('hello world')` in Python A
Metavariable will not be replaced in the `replace` method. You need to create a string using `get_match(var_name)` by using Python.
:::

See also [ast-grep#1172](https://github.com/ast-grep/ast-grep/issues/1172)
See also [ast-grep#1172](https://github.com/ast-grep/ast-grep/issues/1172)

0 comments on commit ff23512

Please sign in to comment.