Skip to content

Commit 7380cd7

Browse files
committed
Add improved docs
1 parent 748289f commit 7380cd7

File tree

1 file changed

+31
-13
lines changed

1 file changed

+31
-13
lines changed

readme.md

+31-13
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
* [Install](#install)
1818
* [Use](#use)
1919
* [API](#api)
20-
* [`toString(node[, options])`](#tostringnode-options)
20+
* [`toString(value[, options])`](#tostringvalue-options)
21+
* [`Options`](#options)
2122
* [Types](#types)
2223
* [Compatibility](#compatibility)
2324
* [Security](#security)
@@ -43,7 +44,7 @@ Similar packages, [`hast-util-to-string`][hast-util-to-string] and
4344
## Install
4445

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

4849
```sh
4950
npm install mdast-util-to-string
@@ -77,33 +78,46 @@ console.log(toString(tree)) // => 'Some emphasis, importance, and code.'
7778

7879
## API
7980

80-
This package exports the identifier `toString`.
81+
This package exports the identifier [`toString`][api-tostring].
8182
There is no default export.
8283

83-
### `toString(node[, options])`
84+
### `toString(value[, options])`
8485

85-
Get the text content of a [node][] or list of nodes.
86-
Prefers the node’s plain-text fields, otherwise serializes its children, and if
87-
the given value is an array, serialize the nodes in it.
86+
Get the text content of a node or list of nodes.
8887

89-
##### `options`
88+
Prefers the node’s plain-text fields, otherwise serializes its children,
89+
and if the given value is an array, serialize the nodes in it.
9090

91-
Configuration (optional).
91+
###### Parameters
9292

93-
###### `options.includeImageAlt`
93+
* `value` (`unknown`)
94+
— thing to serialize, typically [`Node`][node]
95+
* `options` ([`Options`][api-options], optional)
96+
— configuration
9497

95-
Whether to use `alt` (`boolean`, default: `true`).
98+
###### Returns
99+
100+
Serialized `value` (`string`).
101+
102+
### `Options`
103+
104+
Configuration (TypeScript type).
105+
106+
###### Fields
107+
108+
* `includeImageAlt` (`boolean`, default: `true`)
109+
— whether to use `alt` for `image`s
96110

97111
## Types
98112

99113
This package is fully typed with [TypeScript][].
100-
It exports the type `Options`.
114+
It exports the additional type [`Options`][api-options].
101115

102116
## Compatibility
103117

104118
Projects maintained by the unified collective are compatible with all maintained
105119
versions of Node.js.
106-
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
120+
As of now, that is Node.js 14.14+ and 16.0+.
107121
Our projects sometimes work with older versions, but this is not guaranteed.
108122

109123
## Security
@@ -194,3 +208,7 @@ abide by its terms.
194208
[node]: https://github.com/syntax-tree/mdast#nodes
195209

196210
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
211+
212+
[api-tostring]: #tostringvalue-options
213+
214+
[api-options]: #options

0 commit comments

Comments
 (0)