Skip to content

Commit 3a9d6f0

Browse files
fix: sync supported language list
fix ast-grep/ast-grep#1896
1 parent f68cbaf commit 3a9d6f0

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

website/reference/api.md

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ https://github.com/ast-grep/ast-grep/blob/main/crates/napi/index.d.ts
1414

1515
### Supported Languages
1616

17-
`@ast-grep/napi` supports all builtin languages listed [here](/reference/languages.html).
17+
`@ast-grep/napi` supports JS ecosystem languages by default.
18+
More custom languages can be loaded via [`registerDynamicLanguage`](https://github.com/search?q=repo%3Aast-grep%2Flangs%20registerDynamicLanguage&type=code).
1819

1920
#### Type
2021

@@ -25,26 +26,15 @@ export const enum Lang {
2526
Tsx = 'Tsx',
2627
Css = 'Css',
2728
TypeScript = 'TypeScript',
28-
Bash = 'Bash',
29-
C = 'C',
30-
Cpp = 'Cpp',
31-
CSharp = 'CSharp',
32-
Go = 'Go',
33-
Elixir = 'Elixir',
34-
Haskell = 'Haskell',
35-
Java = 'Java',
36-
Json = 'Json',
37-
Kotlin = 'Kotlin',
38-
Lua = 'Lua',
39-
Php = 'Php',
40-
Python = 'Python',
41-
Ruby = 'Ruby',
42-
Rust = 'Rust',
43-
Scala = 'Scala',
44-
Swift = 'Swift'
4529
}
30+
31+
// More custom languages can be loaded
32+
// see https://github.com/ast-grep/langs
33+
type CustomLang = string & {}
4634
```
4735
36+
`CustomLang` is not widely used now. If you have use case and needs support, please file an issue in the [@ast-grep/langs](https://github.com/ast-grep/langs?tab=readme-ov-file#packages) repository.
37+
4838
### Main functions
4939
5040
You can use `parse` to transform a string to ast-grep's main object `SgRoot`.
@@ -203,12 +193,12 @@ interface Edit {
203193
* [Test Case Source](https://github.com/ast-grep/ast-grep/blob/main/crates/napi/__test__/index.spec.ts) for `@ast-grep/napi`
204194
* ast-grep usage in [vue-vine](https://github.com/vue-vine/vue-vine/blob/b661fd2dfb54f2945e7bf5f3691443e05a1ab8f8/packages/compiler/src/analyze.ts#L32)
205195

206-
207196
### Language Object (deprecated) <Badge type="danger" text="Deprecated" />
208197

198+
:::details language objects are deprecated
199+
209200
`ast-grep/napi` also has special language objects for `html`, `js` and `css`. They are deprecated and will be removed in the next version.
210201

211-
:::details
212202
A language object has following methods.
213203

214204
```ts

0 commit comments

Comments
 (0)