Skip to content

Commit 1e9aa74

Browse files
committed
Refactor docs
1 parent 53907b4 commit 1e9aa74

File tree

2 files changed

+76
-49
lines changed

2 files changed

+76
-49
lines changed

lib/types.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@
301301
* Marker to use for bullets of items in unordered lists (default: `'*'`).
302302
* @property {'*' | '+' | '-' | null | undefined} [bulletOther]
303303
* Marker to use in certain cases where the primary bullet doesn’t work
304-
* (optional).
304+
* (default: depends).
305305
*
306306
* There are three cases where the primary bullet cannot be used:
307307
*
@@ -327,7 +327,7 @@
327327
* Marker to use for bullets of items in ordered lists (default: `'.'`).
328328
* @property {'.' | ')' | null | undefined} [bulletOrderedOther]
329329
* Marker to use in certain cases where the primary bullet for ordered items
330-
* doesn’t work (optional).
330+
* doesn’t work (default: none).
331331
*
332332
* There is one case where the primary bullet for ordered items cannot be used:
333333
*

readme.md

Lines changed: 74 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
* [Syntax](#syntax)
3636
* [Syntax tree](#syntax-tree)
3737
* [Types](#types)
38+
* [Compatibility](#compatibility)
3839
* [Security](#security)
3940
* [Related](#related)
4041
* [Contribute](#contribute)
@@ -65,7 +66,7 @@ Notable examples that deeply integrate with it are
6566
## Install
6667

6768
This package is [ESM only][esm].
68-
In Node.js (version 14.14+, or 16.0+), install with [npm][]:
69+
In Node.js (version 16+), install with [npm][]:
6970

7071
```sh
7172
npm install mdast-util-to-markdown
@@ -133,7 +134,8 @@ console.log(toMarkdown(tree))
133134
134135
## API
135136

136-
This package exports the identifiers `toMarkdown` and `defaultHandlers`.
137+
This package exports the identifiers [`defaultHandlers`][api-default-handlers]
138+
and [`toMarkdown`][api-to-markdown].
137139
There is no default export.
138140

139141
### `toMarkdown(tree[, options])`
@@ -144,7 +146,7 @@ Turn an **[mdast][]** syntax tree into markdown.
144146

145147
* `tree` ([`Node`][node])
146148
— tree to serialize
147-
* `options` ([`Options`][options], optional)
149+
* `options` ([`Options`][api-options], optional)
148150
— configuration
149151

150152
###### Returns
@@ -153,7 +155,7 @@ Serialized markdown representing `tree` (`string`).
153155

154156
### `defaultHandlers`
155157

156-
Default (CommonMark) handlers ([`Handlers`][handlers]).
158+
Default (CommonMark) handlers ([`Handlers`][api-handlers]).
157159

158160
### `ConstructName`
159161

@@ -202,9 +204,9 @@ Handle a particular node (TypeScript type).
202204
— expected mdast node
203205
* `parent` ([`Node`][node], optional)
204206
— parent of `node`
205-
* `state` ([`State`][state])
207+
* `state` ([`State`][api-state])
206208
— info passed around about the current state
207-
* `info` ([`Info`][info])
209+
* `info` ([`Info`][api-info])
208210
— info on the surrounding of the node that is serialized
209211

210212
###### Returns
@@ -216,7 +218,7 @@ Serialized markdown representing `node` (`string`).
216218
Handle particular nodes (TypeScript type).
217219

218220
Each key is a node type (`Node['type']`), each value its corresponding handler
219-
([`Handle`][handle]).
221+
([`Handle`][api-handle]).
220222

221223
###### Type
222224

@@ -258,7 +260,7 @@ return defines how many blank lines to use between them.
258260
— second of two adjacent siblings
259261
* `parent` ([`Node`][node])
260262
— parent of the two siblings
261-
* `state` ([`State`][state])
263+
* `state` ([`State`][api-state])
262264
— info passed around about the current state
263265
264266
###### Returns
@@ -383,7 +385,7 @@ Whether to increment the counter of ordered lists items (`boolean`, default:
383385

384386
###### `options.listItemIndent`
385387

386-
How to indent the content of list items (`'one'`, `'tab'`, or `'mixed'`,
388+
How to indent the content of list items (`'mixed'`, `'one'`, or `'tab'`,
387389
default: `'tab'`).
388390
Either with the size of the bullet plus one space (when `'one'`), a tab stop
389391
(`'tab'`), or depending on the item and its parent list (`'mixed'`, uses `'one'`
@@ -429,7 +431,7 @@ Marker to use for strong (`'*'` or `'_'`, default: `'*'`).
429431
Whether to join definitions without a blank line (`boolean`, default: `false`).
430432

431433
The default is to add blank lines between any flow (“block”) construct.
432-
Turning this option on is a shortcut for a [`Join`][join] function like so:
434+
Turning this option on is a shortcut for a [`Join`][api-join] function like so:
433435

434436
```js
435437
function joinTightDefinitions(left, right) {
@@ -441,16 +443,16 @@ function joinTightDefinitions(left, right) {
441443

442444
###### `options.handlers`
443445

444-
Handle particular nodes ([`Handlers`][handlers], optional).
446+
Handle particular nodes ([`Handlers`][api-handlers], optional).
445447

446448
###### `options.join`
447449

448-
How to join blocks ([`Array<Join>`][join], optional).
450+
How to join blocks ([`Array<Join>`][api-join], optional).
449451

450452
###### `options.unsafe`
451453

452-
Schemas that define when characters cannot occur ([`Array<Unsafe>`][unsafe],
453-
optional).
454+
Schemas that define when characters cannot occur
455+
([`Array<Unsafe>`][api-unsafe], optional).
454456

455457
###### `options.extensions`
456458

@@ -479,7 +481,7 @@ Info passed around about the current state (TypeScript type).
479481

480482
###### Fields
481483

482-
* `stack` ([`Array<ConstructName>`][constructname])
484+
* `stack` ([`Array<ConstructName>`][api-construct-name])
483485
— stack of constructs we’re in
484486
* `indexStack` (`Array<number>`)
485487
— positions of child nodes in their parents
@@ -488,27 +490,27 @@ Info passed around about the current state (TypeScript type).
488490
[`Association`][association])
489491
* `enter` (`(construct: ConstructName) => () => undefined`)
490492
— enter a construct (returns a corresponding exit function)
491-
(see [`ConstructName`][constructname])
493+
(see [`ConstructName`][api-construct-name])
492494
* `indentLines` (`(value: string, map: Map) => string`)
493-
— pad serialized markdown (see [`Map`][map])
495+
— pad serialized markdown (see [`Map`][api-map])
494496
* `containerFlow` (`(parent: Node, info: Info) => string`)
495-
— serialize flow children (see [`Info`][info])
497+
— serialize flow children (see [`Info`][api-info])
496498
* `containerPhrasing` (`(parent: Node, info: Info) => string`)
497-
— serialize phrasing children (see [`Info`][info])
499+
— serialize phrasing children (see [`Info`][api-info])
498500
* `createTracker` (`(info: Info) => Tracker`)
499-
— track positional info in the output (see [`Info`][info],
500-
[`Tracker`][tracker])
501+
— track positional info in the output (see [`Info`][api-info],
502+
[`Tracker`][api-tracker])
501503
* `safe` (`(value: string, config: SafeConfig) => string`)
502-
— make a string safe for embedding (see [`SafeConfig`][safeconfig])
503-
* `options` ([`Options`][options])
504+
— make a string safe for embedding (see [`SafeConfig`][api-safe-config])
505+
* `options` ([`Options`][api-options])
504506
— applied user configuration
505-
* `unsafe` ([`Array<Unsafe>`][unsafe])
507+
* `unsafe` ([`Array<Unsafe>`][api-unsafe])
506508
— applied unsafe patterns
507-
* `join` ([`Array<Join>`][join])
509+
* `join` ([`Array<Join>`][api-join])
508510
— applied join handlers
509-
* `handle` ([`Handle`][handle])
511+
* `handle` ([`Handle`][api-handle])
510512
— call the configured handler for the given node
511-
* `handlers` ([`Handlers`][handlers])
513+
* `handlers` ([`Handlers`][api-handlers])
512514
— applied handlers
513515
* `bulletCurrent` (`string` or `undefined`)
514516
— list marker currently in use
@@ -539,11 +541,11 @@ Schema that defines when a character cannot occur (TypeScript type).
539541

540542
* `character` (`string`)
541543
— single unsafe character
542-
* `inConstruct` ([`ConstructName`][constructname], `Array<ConstructName>`,
543-
optional)
544+
* `inConstruct` ([`Array<ConstructName>`][api-construct-name],
545+
`ConstructName`, optional)
544546
— constructs where this is bad
545-
* `notInConstruct` ([`ConstructName`][constructname], `Array<ConstructName>`,
546-
optional)
547+
* `notInConstruct` ([`Array<ConstructName>`][api-construct-name],
548+
`ConstructName`, optional)
547549
— constructs where this is fine again
548550
* `before` (`string`, optional)
549551
`character` is bad when this is before it (cannot be used together with
@@ -595,9 +597,28 @@ The syntax tree is [mdast][].
595597
## Types
596598

597599
This package is fully typed with [TypeScript][].
598-
It exports the additional types `ConstructName`, `ConstructNameMap`, `Handle`,
599-
`Handlers`, `Info` `Join`, `Map`, `Options`, `SafeConfig`, `State`, and
600-
`Unsafe`.
600+
It exports the additional types
601+
[`ConstructName`][api-construct-name],
602+
[`ConstructNameMap`][api-construct-name-map],
603+
[`Handle`][api-handle],
604+
[`Handlers`][api-handlers],
605+
[`Info`][api-info],
606+
[`Join`][api-join],
607+
[`Map`][api-map],
608+
[`Options`][api-options],
609+
[`SafeConfig`][api-safe-config],
610+
[`State`][api-State], and
611+
[`Unsafe`][api-Unsafe].
612+
613+
## Compatibility
614+
615+
Projects maintained by the unified collective are compatible with maintained
616+
versions of Node.js.
617+
618+
When we cut a new major release, we drop support for unmaintained versions of
619+
Node.
620+
This means we try to keep the current release line, `mdast-util-to-markdown@^1`,
621+
compatible with Node.js 12.
601622

602623
## Security
603624

@@ -649,9 +670,9 @@ abide by its terms.
649670

650671
[downloads]: https://www.npmjs.com/package/mdast-util-to-markdown
651672

652-
[size-badge]: https://img.shields.io/bundlephobia/minzip/mdast-util-to-markdown.svg
673+
[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=mdast-util-to-markdown
653674

654-
[size]: https://bundlephobia.com/result?p=mdast-util-to-markdown
675+
[size]: https://bundlejs.com/?q=mdast-util-to-markdown
655676

656677
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
657678

@@ -709,24 +730,30 @@ abide by its terms.
709730

710731
[remark-stringify]: https://github.com/remarkjs/remark/tree/main/packages/remark-stringify
711732

712-
[constructname]: #constructname
733+
[api-construct-name]: #constructname
734+
735+
[api-construct-name-map]: #constructnamemap
736+
737+
[api-default-handlers]: #defaulthandlers
738+
739+
[api-handle]: #handle
713740

714-
[handle]: #handle
741+
[api-handlers]: #handlers
715742

716-
[handlers]: #handlers
743+
[api-info]: #info
717744

718-
[info]: #info
745+
[api-join]: #join
719746

720-
[join]: #join
747+
[api-map]: #map
721748

722-
[map]: #map
749+
[api-options]: #options
723750

724-
[options]: #options
751+
[api-safe-config]: #safeconfig
725752

726-
[safeconfig]: #safeconfig
753+
[api-state]: #state
727754

728-
[state]: #state
755+
[api-to-markdown]: #tomarkdowntree-options
729756

730-
[tracker]: #tracker
757+
[api-tracker]: #tracker
731758

732-
[unsafe]: #unsafe
759+
[api-unsafe]: #unsafe

0 commit comments

Comments
 (0)