Skip to content

Commit d21db0e

Browse files
committed
Add improved docs
1 parent 6ca9397 commit d21db0e

File tree

5 files changed

+125
-75
lines changed

5 files changed

+125
-75
lines changed

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/**
22
* @typedef {import('./lib/parser.js').Buf} Value
33
* @typedef {import('./lib/parser.js').BufferEncoding} BufferEncoding
4-
* @typedef {import('./lib/compiler.js').Options} Options
4+
* @typedef {import('./lib/compiler.js').Options} CompileOptions
5+
* @typedef {import('./lib/from-mdast.js').Options} FromMdastOptions
56
*/
67

78
export {buffer} from './lib/buffer.js'

lib/buffer.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ import {compiler} from './compiler.js'
88
import {parser} from './parser.js'
99

1010
/**
11-
* @param {Buf} buf
12-
* String or buffer to parse.
11+
* Compile gemtext to HTML.
12+
*
13+
* @param {Buf} doc
14+
* Gemtext to parse
1315
* @param {BufferEncoding} [encoding]
1416
* Character encoding to understand `doc` as when it’s a `Buffer`.
1517
* @param {Options} [options]
1618
* Compile configuration (optional).
1719
*/
18-
export function buffer(buf, encoding, options) {
19-
return compiler(options)(parser()(buf, encoding, true))
20+
export function buffer(doc, encoding, options) {
21+
return compiler(options)(parser()(doc, encoding, true))
2022
}

lib/from-gemtext.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import {parser} from './parser.js'
1515

1616
/**
17-
* Parse gemtext to into an AST (gast).
17+
* Parse gemtext to an AST (gast).
1818
* `doc` and `encoding` are the same as the buffering interface.
1919
*
2020
* @param {Buf} doc

lib/from-mdast.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@
3636
* @typedef {import('unist').Node} UnistNode
3737
* @typedef {import('unist').Parent} UnistParent
3838
*
39-
* @typedef Options
40-
* @property {boolean} [tight=false]
41-
* @property {boolean} [endlinks=false]
42-
*
4339
* @typedef Defined
4440
* @property {Record<string, MdastDefinition>} definition
4541
* @property {Record<string, MdastFootnoteDefinition>} footnoteDefinition
@@ -70,6 +66,15 @@
7066
* @property {Queues} queues
7167
* @property {number} link
7268
* @property {number} footnote
69+
*
70+
* @typedef Options
71+
* Configuration (optional).
72+
* @property {boolean} [tight=false]
73+
* Do not put blank lines between blocks.
74+
* The default is to place breaks between each block (paragraph, heading, etc).
75+
* @property {boolean} [endlinks=false]
76+
* Place links at the end of the document.
77+
* The default is to place links before the next heading.
7378
*/
7479

7580
import {visit} from 'unist-util-visit'
@@ -123,8 +128,12 @@ function handle(node, context) {
123128
}
124129

125130
/**
131+
* Transform mdast to gast.
132+
*
126133
* @param {MdastNode} tree
134+
* mdast tree.
127135
* @param {Options} [options]
136+
* Configuration (optional).
128137
* @returns {Array<GastContent>|GastNode|string|void}
129138
*/
130139
export function fromMdast(tree, options) {

0 commit comments

Comments
 (0)