Skip to content

Commit 2e911f8

Browse files
committed
Add improved docs
1 parent a1aba33 commit 2e911f8

File tree

2 files changed

+63
-22
lines changed

2 files changed

+63
-22
lines changed

lib/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@
2929
* Name of marker.
3030
* @property {string} attributes
3131
* Value after name.
32-
* @property {MarkerParameters | null} parameters
33-
* Parsed attributes, with decimal numbers, `true`, and `false` are casted to
34-
* numbers and booleans.
32+
* @property {MarkerParameters} parameters
33+
* Parsed attributes.
3534
* @property {HTML | Mdx1CommentNode | MDXFlowExpression | MDXTextExpression} node
3635
* Reference to given node.
3736
*/
@@ -49,9 +48,9 @@ const markerExpression = new RegExp(
4948
* Parse a comment marker.
5049
*
5150
* @param {unknown} value
52-
* `Node` to parse.
51+
* Thing to parse, typically `Node`.
5352
* @returns {Marker | null}
54-
* Information, when applicable.
53+
* Info when applicable or `null`.
5554
*/
5655
export function commentMarker(value) {
5756
if (

readme.md

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717
* [Install](#install)
1818
* [Use](#use)
1919
* [API](#api)
20-
* [`commentMarker(node)`](#commentmarkernode)
20+
* [`commentMarker(value)`](#commentmarkervalue)
2121
* [`Marker`](#marker)
22+
* [`MarkerParameters`](#markerparameters)
23+
* [`MarkerParameterValue`](#markerparametervalue)
2224
* [Types](#types)
2325
* [Compatibility](#compatibility)
2426
* [Security](#security)
@@ -42,7 +44,7 @@ to replace sections between two markers.
4244
## Install
4345

4446
This package is [ESM only][esm].
45-
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][]:
4648

4749
```sh
4850
npm install mdast-comment-marker
@@ -115,40 +117,74 @@ null
115117

116118
## API
117119

118-
This package exports the identifier `commentMarker`.
120+
This package exports the identifier [`commentMarker`][api-commentmarker].
119121
There is no default export.
120122

121-
### `commentMarker(node)`
123+
### `commentMarker(value)`
122124

123-
Parse a comment marker from `node` ([`Node`][node]).
125+
Parse a comment marker.
126+
127+
###### Parameters
128+
129+
* `value` (`unknown`)
130+
— thing to parse, typically [`Node`][node]
124131

125132
###### Returns
126133

127-
Info, when applicable ([`Marker?`][marker]).
134+
Info ([`Marker`][api-marker]) when applicable or `null`.
128135

129136
### `Marker`
130137

131-
Comment marker.
138+
Comment marker (TypeScript type).
132139

133140
###### Properties
134141

135-
* `name` (`string`) — name of marker
136-
* `attributes` (`string`) — value after name
137-
* `parameters` (`Object`) — parsed attributes, with decimal numbers, `true`,
138-
and `false` are casted to numbers and booleans
139-
* `node` ([`Node`][node]) — reference to given node
142+
* `name` (`string`)
143+
— name of marker
144+
* `attributes` (`string`)
145+
— value after name
146+
* `parameters` ([`MarkerParameters`][api-markerparameters])
147+
— parsed attributes
148+
* `node` ([`Node`][node])
149+
— reference to given node
150+
151+
### `MarkerParameters`
152+
153+
Parameters (TypeScript type).
154+
155+
###### type
156+
157+
```ts
158+
type MarkerParameters = Record<string, MarkerParameterValue>
159+
```
160+
161+
### `MarkerParameterValue`
162+
163+
Value (TypeScript type).
164+
165+
If it looks like a number (to JavaScript), it’s cast as number.
166+
The strings `true` and `false` are turned into their corresponding
167+
booleans.
168+
The empty string is also considered the `true` boolean.
169+
170+
###### type
171+
172+
```ts
173+
type MarkerParameterValue = string | number | boolean
174+
```
140175
141176
## Types
142177
143178
This package is fully typed with [TypeScript][].
144-
This package exports the types `Marker`, `MarkerParameterValue`, and
145-
`MarkerParameters`.
179+
This package exports the types [`Marker`][api-marker],
180+
[`MarkerParameters`][api-markerparameters], and
181+
[`MarkerParameterValue`][api-markerparametervalue]
146182
147183
## Compatibility
148184
149185
Projects maintained by the unified collective are compatible with all maintained
150186
versions of Node.js.
151-
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
187+
As of now, that is Node.js 14.14+ and 16.0+.
152188
Our projects sometimes work with older versions, but this is not guaranteed.
153189
154190
## Security
@@ -228,12 +264,18 @@ abide by its terms.
228264
229265
[node]: https://github.com/syntax-tree/unist#node
230266
231-
[marker]: #marker
232-
233267
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
234268
235269
[hast]: https://github.com/syntax-tree/hast
236270
237271
[remark-lint]: https://github.com/remarkjs/remark-lint
238272
239273
[mdast-zone]: https://github.com/syntax-tree/mdast-zone
274+
275+
[api-commentmarker]: #commentmarkervalue
276+
277+
[api-marker]: #marker
278+
279+
[api-markerparameters]: #markerparameters
280+
281+
[api-markerparametervalue]: #markerparametervalue

0 commit comments

Comments
 (0)