Skip to content

Commit b61d599

Browse files
authored
Proofread quick-start.md (#837)
* Proofread quick-start.md I did some proofreading and grammar checking on the quick start. Hopefully this is helpful since most users will land here first! * Second pass quick-start.md
1 parent 5b47c44 commit b61d599

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

website/guide/quick-start.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ head:
88

99
# Quick Start
1010

11-
You can unleash `ast-grep`'s power at your finger tips within few keystrokes in command line!
11+
You can unleash `ast-grep`'s power at your fingertips in a few keystrokes on the command line!
1212

13-
Let's try its power of by rewriting some code in a moderately large codebase: [TypeScript](https://github.com/microsoft/TypeScript/).
13+
Let's see it in action by rewriting code in a moderately large codebase: [TypeScript](https://github.com/microsoft/TypeScript/).
1414

15-
Our task is to rewrite old defensive code that checks nullable nested method calls to the new shiny [optional chaining operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining) `?.`.
15+
Our task is to rewrite old defensive code that checks nullable nested method calls to use the shiny new [optional chaining operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining) `?.`.
1616

1717
## Installation
1818
First, install `ast-grep`. It is distributed by [npm](https://www.npmjs.com/package/@ast-grep/cli), [cargo](https://crates.io/crates/ast-grep), [homebrew](https://formulae.brew.sh/formula/ast-grep) and [macports](https://ports.macports.org/port/ast-grep/). You can also build it [from source](https://github.com/ast-grep/ast-grep#installation).
@@ -72,9 +72,9 @@ git clone [email protected]:microsoft/TypeScript.git --depth 1
7272
```
7373

7474
## Pattern
75-
Then search the occurrence of looking up a method from a nested structure. `ast-grep` uses **pattern** to find similar code.
76-
Think it as the pattern in our old-friend `grep` but it matches AST node instead of text.
77-
We can write pattern as if write ordinary code. It will match all code that has the same syntactical structure.
75+
Let's search for instances of calling a method on a nested property. `ast-grep` uses **patterns** to find similar code.
76+
Think of patterns like those in our old friend `grep`, but instead of text, they match AST nodes.
77+
We can write patterns like we write ordinary code, and it will match all code that has the same syntactical structure.
7878

7979
For example, the following pattern code
8080

@@ -93,18 +93,18 @@ const result = obj.val &&
9393
obj.val()
9494
```
9595

96-
Matching based exactly on AST is cool, but we certainly want to use flexible pattern to match code with infinite possibility.
97-
We can use **meta variable** to match any single AST node. Meta variable begins with `$` sign with upper case letters following, e.g. `$METAVAR`.
98-
Think it as REGEX dot `.`, except it is not textual.
96+
Exact AST matching is already powerful, but we can go further with **metavariables** for more flexibility.
97+
Use a **metavariable** to match any single AST node. Metavariables begin with `$` and are typically uppercase (e.g., `$PROP`).
98+
Think of it like the regex dot `.`, except it matches syntax nodes, not text.
9999

100-
We can write this pattern to find all property checking code.
100+
We can use the following pattern to find all property checking code.
101101

102102
```javascript
103103
$PROP && $PROP()
104104
```
105105

106-
It is a valid `ast-grep` pattern! We can use it in command line! Use `pattern` argument to specify our target.
107-
Optionally, we can use `lang` to tell ast-grep our target code language.
106+
This is a valid `ast-grep` pattern you can run from the command line. The `--pattern` argument specifies the target.
107+
Optionally, use `--lang` to specify the target language.
108108

109109
:::code-group
110110
```shell [Full Command]
@@ -120,15 +120,15 @@ ast-grep -p '$PROP && $PROP()' TypeScript/src
120120
:::
121121

122122
:::tip Pro Tip
123-
Pattern must be quoted by single quote `'` to prevent shell from interpreting `$` sign.
123+
The pattern must be enclosed in single quotes `'` to prevent the shell from interpreting the `$` sign.
124124
`ast-grep -p '$PROP && $PROP()'` is okay.
125125

126-
But `ast-grep -p "$PROP && $PROP()"` will be interpreted as `ast-grep -p " && ()"` after shell expansion.
126+
With double quotes, `ast-grep -p "$PROP && $PROP()"` would be interpreted as `ast-grep -p " && ()"` after shell expansion.
127127
:::
128128

129129
## Rewrite
130130

131-
Cool? Now we can use this pattern to refactor TypeScript source!
131+
Cool? Now we can use this pattern to refactor the TypeScript source!
132132

133133
```shell
134134
# pattern and language argument support short form
@@ -139,13 +139,13 @@ ast-grep -p '$PROP && $PROP()' \
139139
TypeScript/src
140140
```
141141

142-
ast-grep will start an interactive session to let you choose if you want to apply the patch.
142+
`ast-grep` will start an interactive session to let you choose if you want to apply the patch.
143143
Press `y` to accept the change!
144144

145145

146-
That's it! You have refactored TypeScript's repository in minutes. Congratulation!
146+
That's it! You have refactored the TypeScript source in minutes. Congratulations!
147147

148-
Hope you enjoy the power of AST editing in plain programming language pattern. Our next step is to know more about the pattern code.
148+
We hope you enjoy the power of AST editing with plain programming-language patterns. Next, learn more about writing patterns.
149149

150150
:::tip Pattern does not work?
151151
See our FAQ for more [guidance](/advanced/faq.html) on writing patterns.

0 commit comments

Comments
 (0)