Skip to content

Commit 9f5f91c

Browse files
fix: add deprecation
1 parent c8da0d7 commit 9f5f91c

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

website/reference/api.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -198,26 +198,28 @@ interface Edit {
198198
* ast-grep usage in [vue-vine](https://github.com/vue-vine/vue-vine/blob/b661fd2dfb54f2945e7bf5f3691443e05a1ab8f8/packages/compiler/src/analyze.ts#L32)
199199

200200

201-
### Language Object (deprecated)
201+
### Language Object (deprecated) <Badge type="danger" text="Deprecated" />
202202

203-
`ast-grep/napi` also has special language objects for `html`, `js` and `css`.
203+
`ast-grep/napi` also has special language objects for `html`, `js` and `css`. They are deprecated and will be removed in the next version.
204204

205+
:::details
205206
A language object has following methods.
206207

207208
```ts
208-
export namespace js {
209-
/** Parse a string to an ast-grep instance */
209+
/**
210+
* @deprecated language specific objects are deprecated
211+
* use the equivalent functions like `parse` in @ast-grep/napi
212+
*/
213+
export declare namespace js {
214+
/** @deprecated use `parse(Lang.JavaScript, src)` instead */
210215
export function parse(src: string): SgRoot
211-
/** Get the `kind` number from its string name. */
216+
/** @deprecated use `parseAsync(Lang.JavaScript, src)` instead */
217+
export function parseAsync(src: string): Promise<SgRoot>
218+
/** @deprecated use `kind(Lang.JavaScript, kindName)` instead */
212219
export function kind(kindName: string): number
213-
/** Compile a string to ast-grep Pattern. */
220+
/** @deprecated use `pattern(Lang.JavaScript, p)` instead */
214221
export function pattern(pattern: string): NapiConfig
215-
/**
216-
* Discover and parse multiple files in Rust.
217-
* `config` specifies the file path and matcher.
218-
* `callback` will receive matching nodes found in a file.
219-
* returns the number of matched files.
220-
*/
222+
/** @deprecated use `findInFiles(Lang.JavaScript, config, callback)` instead */
221223
export function findInFiles(
222224
config: FindConfig,
223225
callback: (err: null | Error, result: SgNode[]) => void
@@ -234,6 +236,8 @@ const source = `console.log("hello world")`
234236
const ast = js.parse(source)
235237
```
236238
239+
:::
240+
237241
## Python API
238242
239243
### SgRoot

0 commit comments

Comments
 (0)