Skip to content

Commit

Permalink
doc: add doc for using other languages
Browse files Browse the repository at this point in the history
fix #446
  • Loading branch information
HerringtonDarkholme committed Jun 24, 2024
1 parent 3770b67 commit d4c952a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions website/guide/api-usage/js-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,18 @@ const newSource = node.commitEdits([edit])
```

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

## Use Other Language

To access other languages, you can use the `parse`/`parseAsync` function and the `Lang` enum.


**Example**

```js
import { parse, Lang } from '@ast-grep/napi'

const sg = parse('def test(): pass', Lang.Python)

console.log(sg.root().has('function_definition'))
```

0 comments on commit d4c952a

Please sign in to comment.