Skip to content

Commit c05e153

Browse files
committed
Add improved docs
1 parent 65378cd commit c05e153

File tree

3 files changed

+253
-56
lines changed

3 files changed

+253
-56
lines changed

dev/index.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
/**
2-
* @typedef {import('./lib/index.js').Value} Value
2+
* @typedef {import('./lib/index.js').CompileContext} CompileContext
33
* @typedef {import('./lib/index.js').Encoding} Encoding
4-
* @typedef {import('./lib/index.js').Options} Options
54
* @typedef {import('./lib/index.js').Extension} Extension
65
* @typedef {import('./lib/index.js').Handle} Handle
7-
* @typedef {import('./lib/index.js').Transform} Transform
8-
* @typedef {import('./lib/index.js').Token} Token
9-
* @typedef {import('./lib/index.js').CompileContext} CompileContext
106
* @typedef {import('./lib/index.js').OnEnterError} OnEnterError
117
* @typedef {import('./lib/index.js').OnExitError} OnExitError
12-
*
8+
* @typedef {import('./lib/index.js').Options} Options
9+
* @typedef {import('./lib/index.js').Token} Token
10+
* @typedef {import('./lib/index.js').Transform} Transform
11+
* @typedef {import('./lib/index.js').Value} Value
12+
*/
13+
14+
/**
1315
* @typedef {import('./lib/index.js').OnEnterError} OnError
14-
* To do: deprecate next major.
16+
* To do: next major: remove.
1517
*/
1618

1719
export {fromMarkdown} from './lib/index.js'

dev/lib/index.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
* @param {Root} tree
6565
* Tree to transform.
6666
* @returns {Root | undefined | null | void}
67-
* New tree (the default is to assume the tree is mutated).
67+
* New tree or nothing (in which case the current tree is used).
6868
*
6969
* @callback Handle
7070
* Handle a token.
@@ -92,7 +92,7 @@
9292
*
9393
* @callback OnExitError
9494
* Handle the case where the `right` token is open but it is closed by
95-
* exitting the `left` token.
95+
* exiting the `left` token.
9696
* @param {Omit<CompileContext, 'sliceSerialize'>} this
9797
* Context.
9898
* @param {Token} left
@@ -125,15 +125,15 @@
125125
* Change how markdown tokens from micromark are turned into mdast.
126126
*
127127
* @typedef CompileContext
128-
* mdast compiler context
128+
* mdast compiler context.
129129
* @property {Array<Node | Fragment>} stack
130130
* Stack of nodes.
131131
* @property {Array<TokenTuple>} tokenStack
132132
* Stack of tokens.
133-
* @property {<Key extends keyof CompileData>(key: Key, value?: CompileData[Key]) => void} setData
134-
* Set data into the key-value store.
135133
* @property {<Key extends keyof CompileData>(key: Key) => CompileData[Key]} getData
136-
* Get data from the key-value store.
134+
* Get data from the key/value store.
135+
* @property {<Key extends keyof CompileData>(key: Key, value?: CompileData[Key]) => void} setData
136+
* Set data into the key/value store.
137137
* @property {(this: CompileContext) => void} buffer
138138
* Capture some of the output data.
139139
* @property {(this: CompileContext) => string} resume
@@ -150,9 +150,10 @@
150150
* @typedef FromMarkdownOptions
151151
* Configuration for how to build mdast.
152152
* @property {Array<Extension | Array<Extension>> | null | undefined} [mdastExtensions]
153-
* Extensions to change how tokens are turned into a tree.
153+
* Extensions for this utility to change how tokens are turned into a tree.
154154
*
155155
* @typedef {ParseOptions & FromMarkdownOptions} Options
156+
* Configuration.
156157
*/
157158

158159
// To do: micromark: create a registry of tokens?
@@ -177,9 +178,9 @@ const own = {}.hasOwnProperty
177178

178179
/**
179180
* @param value
180-
* Markdown to parse (`string` or `Buffer`).
181+
* Markdown to parse.
181182
* @param encoding
182-
* Character encoding to understand `value` as when it’s a `Buffer` (`string`, default: `'utf8'`).
183+
* Character encoding for when `value` is `Buffer`.
183184
* @param options
184185
* Configuration.
185186
* @returns

0 commit comments

Comments
 (0)