From 27d84ac92f8894de4e02db11980d144e79e354e9 Mon Sep 17 00:00:00 2001 From: Alex Bit <78109534+alexbit-codemod@users.noreply.github.com> Date: Wed, 17 Apr 2024 20:45:09 -0700 Subject: [PATCH] fixing typo root.root to ast.root --- website/guide/api-usage/js-api.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/guide/api-usage/js-api.md b/website/guide/api-usage/js-api.md index 8e076f6d..29d2c7c1 100644 --- a/website/guide/api-usage/js-api.md +++ b/website/guide/api-usage/js-api.md @@ -37,7 +37,7 @@ Remember your old time web programming? A common workflow to use ast-grep's JavaScript API is: 1. Get a syntax tree object `SgRoot` from string by calling a language's `parse` method -2. Get the root node of the syntax tree by calling `root.root()` +2. Get the root node of the syntax tree by calling `ast.root()` 3. `find` relevant nodes by using patterns or rules 4. Collect information from the nodes @@ -191,7 +191,7 @@ export class SgNode { ```ts{3} const ast = js.parse("console.log('hello world')") -root = root.root() +root = ast.root() root.text() // will return "console.log('hello world')" ``` @@ -344,4 +344,4 @@ let fileCount = await js.findInFiles({ t.assert(n.length > 0) t.assert(n[0].text().includes('.')) }) -``` \ No newline at end of file +```