Skip to content

Commit d30b30d

Browse files
committed
Add improved docs
1 parent 4ec77a0 commit d30b30d

File tree

2 files changed

+40
-7
lines changed

2 files changed

+40
-7
lines changed

lib/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
/**
22
* @typedef {import('unist').Node} Node
3-
* @typedef {import('unist').Parent} Parent
4-
* @typedef {import('unist').Literal} Literal
5-
* @typedef {Record<string, unknown>} Props
3+
*/
4+
5+
/**
66
* @typedef {Array<Node> | string} ChildrenOrValue
7+
* List to use as `children` or value to use as `value`.
8+
*
9+
* @typedef {Record<string, unknown>} Props
10+
* Other fields to add to the node.
711
*/
812

913
/**

readme.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* [Use](#use)
1919
* [API](#api)
2020
* [`u(type[, props][, children|value])`](#utype-props-childrenvalue)
21+
* [`ChildrenOrValue`](#childrenorvalue)
22+
* [`Props`](#props)
2123
* [Types](#types)
2224
* [Compatibility](#compatibility)
2325
* [Related](#related)
@@ -42,7 +44,7 @@ when creating hast (HTML) or xast (XML) nodes.
4244
## Install
4345

4446
This package is [ESM only][esm].
45-
In Node.js (version 12.20+, 14.14+, 16.0+, or 18.0+), install with [npm][]:
47+
In Node.js (version 14.14+ and 16.0+), install with [npm][]:
4648

4749
```sh
4850
npm install unist-builder
@@ -107,7 +109,7 @@ results in the following tree:
107109

108110
## API
109111

110-
This package exports the identifier `u`.
112+
This package exports the identifier [`u`][u].
111113
There is no default export.
112114

113115
### `u(type[, props][, children|value])`
@@ -135,16 +137,37 @@ Build a node.
135137

136138
Built node ([`Node`][node]).
137139

140+
### `ChildrenOrValue`
141+
142+
List to use as `children` or value to use as `value` (TypeScript type).
143+
144+
###### Type
145+
146+
```ts
147+
type ChildrenOrValue = Array<Node> | string
148+
```
149+
150+
### `Props`
151+
152+
Other fields to add to the node (TypeScript type).
153+
154+
###### Type
155+
156+
```ts
157+
export type Props = Record<string, unknown>
158+
```
159+
138160
## Types
139161
140162
This package is fully typed with [TypeScript][].
141-
It exports the additional types `Props` and `ChildrenOrValue`.
163+
It exports the additional types [`ChildrenOrValue`][childrenorvalue] and
164+
[`Props`][props].
142165
143166
## Compatibility
144167
145168
Projects maintained by the unified collective are compatible with all maintained
146169
versions of Node.js.
147-
As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
170+
As of now, that is Node.js 14.14+ and 16.0+.
148171
Our projects sometimes work with older versions, but this is not guaranteed.
149172
150173
## Related
@@ -229,3 +252,9 @@ abide by its terms.
229252
[hastscript]: https://github.com/syntax-tree/hastscript
230253
231254
[xastscript]: https://github.com/syntax-tree/xastscript
255+
256+
[u]: #utype-props-childrenvalue
257+
258+
[props]: #props
259+
260+
[childrenorvalue]: #childrenorvalue

0 commit comments

Comments
 (0)