docs(plugins): add parser.preprocess (#4365)

* docs(plugins): add parser.preprocess

* docs: fix linting
master
Ika 2018-04-25 00:41:39 +08:00 committed by GitHub
parent 6a17474e37
commit 6b2be99b53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -87,7 +87,8 @@ export const parsers = {
astFormat: "dance-ast",
hasPragma,
locStart,
locEnd
locEnd,
preprocess
}
};
```
@ -104,12 +105,18 @@ The location extraction functions (`locStart` and `locEnd`) return the starting
function locStart(node: object): number;
```
The pragma detection function (`hasPragma`) should return if the text contains the pragma comment.
_(Optional)_ The pragma detection function (`hasPragma`) should return if the text contains the pragma comment.
```ts
function hasPragma(text: string): boolean;
```
_(Optional)_ The preprocess function can process the input text before passing into `parse` function.
```ts
function preprocess(text: string, options: object): string;
```
### `printers`
Printers convert ASTs into a Prettier intermediate representation, also known as a Doc.