Skip to content

Commit

Permalink
Add improved docs
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jun 5, 2022
1 parent b3f967a commit b7ad993
Showing 1 changed file with 82 additions and 20 deletions.
102 changes: 82 additions & 20 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,61 @@
[![Backers][backers-badge]][collective]
[![Chat][chat-badge]][chat]

[**unist**][unist] utility to check if a [node][] is [*generated*][generated].
[unist][] utility to check if a node is generated.

## Install
## Contents

* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Install](#install)
* [Use](#use)
* [API](#api)
* [`generated(node)`](#generatednode)
* [Types](#types)
* [Compatibility](#compatibility)
* [Related](#related)
* [Contribute](#contribute)
* [License](#license)

## What is this?

This utility can be used to check if a node is said to be [generated][].

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

[npm][]:
You can use this utility to check is generated.
Generated nodes were not in the source of the original file, and thus not
authored by a human.
This info can then be used to not emit lint messages for generated content.

You might also find the utility [`unist-util-position`][unist-util-position]
useful to get clean positional info.
To display positional info to users, use
[`unist-util-stringify-position`][unist-util-stringify-position].

## Install

This package is [ESM only][esm].
In Node.js (version 12.20+, 14.14+, 16.0+, 18.0+), install with [npm][]:

```sh
npm install unist-util-generated
```

In Deno with [`esm.sh`][esmsh]:

```js
import {generated} from "https://esm.sh/unist-util-generated@2"
```

In browsers with [`esm.sh`][esmsh]:

```html
<script type="module">
import {generated} from "https://esm.sh/unist-util-generated@2?bundle"
</script>
```

## Use

```js
Expand All @@ -37,36 +79,44 @@ generated({

## API

This package exports the following identifiers: `generated`.
This package exports the identifier `generated`.
There is no default export.

### `generated(node)`

Check if [`node`][node] is [*generated*][generated].
Check if `node` ([`Node`][node]) is *[generated][]*.

###### Returns

###### Parameters
Whether `node` is generated (`boolean`).

* `node` ([`Node`][node]) — Node to check.
## Types

###### Returns
This package is fully typed with [TypeScript][].
It exports no additional types.

## Compatibility

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

## Related

* [`unist-util-position`](https://github.com/syntax-tree/unist-util-position)
Get the position of nodes
get the position of nodes
* [`unist-util-source`](https://github.com/syntax-tree/unist-util-source)
Get the source of a node or position
get the source of a node or position
* [`unist-util-remove-position`](https://github.com/syntax-tree/unist-util-remove-position)
Remove `position`s from a tree
remove `position`s
* [`unist-util-stringify-position`](https://github.com/syntax-tree/unist-util-stringify-position)
Stringify a node, position, or point
serialize positional info

## Contribute

See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
started.
See [`contributing.md`][contributing] in [`syntax-tree/.github`][health] for
ways to get started.
See [`support.md`][support] for ways to get help.

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

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

[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

[esmsh]: https://esm.sh

[typescript]: https://www.typescriptlang.org

[license]: license

[author]: https://wooorm.com

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

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

[coc]: https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct.md
[support]: https://github.com/syntax-tree/.github/blob/main/support.md

[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md

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

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

[generated]: https://github.com/syntax-tree/unist#generated

[unist-util-position]: https://github.com/syntax-tree/unist-util-position

[unist-util-stringify-position]: https://github.com/syntax-tree/unist-util-stringify-position

0 comments on commit b7ad993

Please sign in to comment.