Skip to content

Commit b7ad993

Browse files
committed
Add improved docs
1 parent b3f967a commit b7ad993

File tree

1 file changed

+82
-20
lines changed

1 file changed

+82
-20
lines changed

readme.md

+82-20
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,61 @@
88
[![Backers][backers-badge]][collective]
99
[![Chat][chat-badge]][chat]
1010

11-
[**unist**][unist] utility to check if a [node][] is [*generated*][generated].
11+
[unist][] utility to check if a node is generated.
1212

13-
## Install
13+
## Contents
14+
15+
* [What is this?](#what-is-this)
16+
* [When should I use this?](#when-should-i-use-this)
17+
* [Install](#install)
18+
* [Use](#use)
19+
* [API](#api)
20+
* [`generated(node)`](#generatednode)
21+
* [Types](#types)
22+
* [Compatibility](#compatibility)
23+
* [Related](#related)
24+
* [Contribute](#contribute)
25+
* [License](#license)
26+
27+
## What is this?
28+
29+
This utility can be used to check if a node is said to be [generated][].
1430

15-
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
16-
Node 12+ is needed to use it and it must be `import`ed instead of `require`d.
31+
## When should I use this?
1732

18-
[npm][]:
33+
You can use this utility to check is generated.
34+
Generated nodes were not in the source of the original file, and thus not
35+
authored by a human.
36+
This info can then be used to not emit lint messages for generated content.
37+
38+
You might also find the utility [`unist-util-position`][unist-util-position]
39+
useful to get clean positional info.
40+
To display positional info to users, use
41+
[`unist-util-stringify-position`][unist-util-stringify-position].
42+
43+
## Install
44+
45+
This package is [ESM only][esm].
46+
In Node.js (version 12.20+, 14.14+, 16.0+, 18.0+), install with [npm][]:
1947

2048
```sh
2149
npm install unist-util-generated
2250
```
2351

52+
In Deno with [`esm.sh`][esmsh]:
53+
54+
```js
55+
import {generated} from "https://esm.sh/unist-util-generated@2"
56+
```
57+
58+
In browsers with [`esm.sh`][esmsh]:
59+
60+
```html
61+
<script type="module">
62+
import {generated} from "https://esm.sh/unist-util-generated@2?bundle"
63+
</script>
64+
```
65+
2466
## Use
2567

2668
```js
@@ -37,36 +79,44 @@ generated({
3779

3880
## API
3981

40-
This package exports the following identifiers: `generated`.
82+
This package exports the identifier `generated`.
4183
There is no default export.
4284

4385
### `generated(node)`
4486

45-
Check if [`node`][node] is [*generated*][generated].
87+
Check if `node` ([`Node`][node]) is *[generated][]*.
88+
89+
###### Returns
4690

47-
###### Parameters
91+
Whether `node` is generated (`boolean`).
4892

49-
* `node` ([`Node`][node]) — Node to check.
93+
## Types
5094

51-
###### Returns
95+
This package is fully typed with [TypeScript][].
96+
It exports no additional types.
97+
98+
## Compatibility
5299

53-
`boolean` — Whether `node` is generated.
100+
Projects maintained by the unified collective are compatible with all maintained
101+
versions of Node.js.
102+
As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
103+
Our projects sometimes work with older versions, but this is not guaranteed.
54104

55105
## Related
56106

57107
* [`unist-util-position`](https://github.com/syntax-tree/unist-util-position)
58-
Get the position of nodes
108+
get the position of nodes
59109
* [`unist-util-source`](https://github.com/syntax-tree/unist-util-source)
60-
Get the source of a node or position
110+
get the source of a node or position
61111
* [`unist-util-remove-position`](https://github.com/syntax-tree/unist-util-remove-position)
62-
Remove `position`s from a tree
112+
remove `position`s
63113
* [`unist-util-stringify-position`](https://github.com/syntax-tree/unist-util-stringify-position)
64-
Stringify a node, position, or point
114+
serialize positional info
65115

66116
## Contribute
67117

68-
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
69-
started.
118+
See [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for
119+
ways to get started.
70120
See [`support.md`][support] for ways to get help.
71121

72122
This project has a [code of conduct][coc].
@@ -107,18 +157,30 @@ abide by its terms.
107157

108158
[npm]: https://docs.npmjs.com/cli/install
109159

160+
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
161+
162+
[esmsh]: https://esm.sh
163+
164+
[typescript]: https://www.typescriptlang.org
165+
110166
[license]: license
111167

112168
[author]: https://wooorm.com
113169

114-
[contributing]: https://github.com/syntax-tree/.github/blob/HEAD/contributing.md
170+
[health]: https://github.com/syntax-tree/.github
115171

116-
[support]: https://github.com/syntax-tree/.github/blob/HEAD/support.md
172+
[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md
117173

118-
[coc]: https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct.md
174+
[support]: https://github.com/syntax-tree/.github/blob/main/support.md
175+
176+
[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md
119177

120178
[unist]: https://github.com/syntax-tree/unist
121179

122180
[node]: https://github.com/syntax-tree/unist#node
123181

124182
[generated]: https://github.com/syntax-tree/unist#generated
183+
184+
[unist-util-position]: https://github.com/syntax-tree/unist-util-position
185+
186+
[unist-util-stringify-position]: https://github.com/syntax-tree/unist-util-stringify-position

0 commit comments

Comments
 (0)