Skip to content

Commit 3a1a2fc

Browse files
committed
docs: when should i use this?
Signed-off-by: Lexus Drumgold <[email protected]>
1 parent 1c7c3ae commit 3a1a2fc

File tree

5 files changed

+28
-31
lines changed

5 files changed

+28
-31
lines changed

.github/infrastructure.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ repository:
171171
automated_security_fixes: true
172172
default_branch: main
173173
delete_branch_on_merge: true
174-
description: unified compliant parser for docast
174+
description: unified plugin to add support for parsing docblock comments
175175
has_issues: true
176176
has_projects: true
177177
has_wiki: false
@@ -186,23 +186,19 @@ repository:
186186
squash_merge_commit_message: BLANK
187187
squash_merge_commit_title: PR_TITLE
188188
topics:
189-
- abstract-syntax-tree
190189
- ast
191190
- comment-parser
192-
- doc
193191
- docast
194192
- docblock
193+
- docs
195194
- documentation
196195
- jsdoc
197196
- markdown
198197
- mdast
199198
- syntax-tree
200199
- tsdoc
201-
- typedoc
202200
- typescript
203201
- unified
204-
- unist
205-
- unist-spec
206202
visibility: public
207203
vulnerability_alerts: true
208204
web_commit_signoff_required: true

README.md

+14-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[![vitest](https://img.shields.io/badge/-vitest-6e9f18?style=flat&logo=vitest&logoColor=ffffff)](https://vitest.dev/)
1111
[![yarn](https://img.shields.io/badge/-yarn-2c8ebb?style=flat&logo=yarn&logoColor=ffffff)](https://yarnpkg.com/)
1212

13-
[**unified**][unified] compliant parser for [**docast**][docast].
13+
[**docast**][docast] x [**unified**][unified] plugin to add support for parsing docblock comments.
1414

1515
## Contents
1616

@@ -26,12 +26,17 @@
2626

2727
## What is this?
2828

29-
This package is a [unified][unified] plugin that defines how to take source code as input and turn it into a [docblock
30-
syntax tree][docast].
29+
This package is a [unified][unified] plugin that defines how to take [docblock][docblock] input and turn it into a
30+
syntax tree.
3131

3232
## When should I use this?
3333

34-
**TODO**: when should i use this?
34+
This plugin adds support to unified for parsing [docblock comments][docblock]. If you don’t use plugins and want to
35+
access the syntax tree directly, you can use [`docast-util-from-docs`][docast-util-from-docs] instead.
36+
37+
You can also combine this plugin with other unified plugins to add extensions for parsing markdown in docblock comments.
38+
Notable packages include [`remark-directive`][remark-directive], [`remark-gfm`][remark-gfm], and
39+
[`remark-math`][remark-math].
3540

3641
## Install
3742

@@ -89,9 +94,14 @@ This package is fully typed with [TypeScript][typescript].
8994

9095
See [`CONTRIBUTING.md`](CONTRIBUTING.md).
9196

97+
[docast-util-from-docs]: https://github.com/flex-development/docast-util-from-docs
9298
[docast]: https://github.com/flex-development/docast
99+
[docblock]: https://github.com/flex-development/docast#docblock-comment
93100
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
94101
[esmsh]: https://esm.sh/
102+
[remark-directive]: https://github.com/remarkjs/remark-directive
103+
[remark-gfm]: https://github.com/remarkjs/remark-gfm
104+
[remark-math]: https://github.com/remarkjs/remark-math
95105
[typescript]: https://www.typescriptlang.org
96106
[unified]: https://github.com/unifiedjs/unified
97107
[yarn]: https://yarnpkg.com

package.json

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
11
{
22
"name": "@flex-development/docast-parse",
3-
"description": "unified compliant parser for docast",
3+
"description": "unified plugin to add support for parsing docblock comments",
44
"version": "1.0.0-alpha.5",
55
"keywords": [
6-
"abstract-syntax-tree",
76
"ast",
87
"comment-parser",
9-
"doc",
108
"docast",
119
"docblock",
10+
"docs",
1211
"documentation",
1312
"jsdoc",
1413
"markdown",
1514
"mdast",
1615
"syntax-tree",
1716
"tsdoc",
18-
"typedoc",
1917
"typescript",
20-
"unified",
21-
"unist",
22-
"unist-spec"
18+
"unified"
2319
],
2420
"license": "BSD-3-Clause",
2521
"homepage": "https://github.com/flex-development/docast-parse",
@@ -139,9 +135,7 @@
139135
"is-ci": "3.0.1",
140136
"jsonc-eslint-parser": "2.4.0",
141137
"lint-staged": "15.2.1",
142-
"mdast-util-directive": "3.0.0",
143138
"mdast-util-from-markdown": "2.0.0",
144-
"micromark-extension-directive": "3.0.0",
145139
"micromark-util-types": "2.0.0",
146140
"node-notifier": "10.0.1",
147141
"prettier": "3.2.4",

src/__tests__/plugin.integration.spec.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
import type { Options } from '@flex-development/docast-util-from-docs'
77
import { constant, type Nilable } from '@flex-development/tutils'
8-
import { directiveFromMarkdown } from 'mdast-util-directive'
9-
import { directive } from 'micromark-extension-directive'
8+
import remarkDirective from 'remark-directive'
109
import { read } from 'to-vfile'
1110
import { unified } from 'unified'
1211
import { inspectNoColor } from 'unist-util-inspect'
@@ -24,10 +23,7 @@ describe('integration:plugin', () => {
2423

2524
describe.each<['empty' | 'non-empty', Nilable<Options>?]>([
2625
['empty'],
27-
['non-empty', {
28-
mdastExtensions: [directiveFromMarkdown()],
29-
micromarkExtensions: [directive()]
30-
}]
26+
['non-empty', { transforms: [vi.fn()] }]
3127
])('%s document', (type, options) => {
3228
let file: VFile
3329
let value: string
@@ -37,9 +33,12 @@ describe('integration:plugin', () => {
3733
file = type === 'empty' ? new VFile(value) : await read(value)
3834
})
3935

40-
it('should configure parser', async () => {
36+
it('should configure parser', () => {
4137
// Act
42-
const result = unified().use(testSubject, options).parse(file)
38+
const result = unified()
39+
.use(testSubject, options)
40+
.use(remarkDirective)
41+
.parse(file)
4342

4443
// Expect
4544
expect(result).toMatchSnapshot()

yarn.lock

+2-4
Original file line numberDiff line numberDiff line change
@@ -1457,9 +1457,7 @@ __metadata:
14571457
is-ci: "npm:3.0.1"
14581458
jsonc-eslint-parser: "npm:2.4.0"
14591459
lint-staged: "npm:15.2.1"
1460-
mdast-util-directive: "npm:3.0.0"
14611460
mdast-util-from-markdown: "npm:2.0.0"
1462-
micromark-extension-directive: "npm:3.0.0"
14631461
micromark-util-types: "npm:2.0.0"
14641462
node-notifier: "npm:10.0.1"
14651463
prettier: "npm:3.2.4"
@@ -7060,7 +7058,7 @@ __metadata:
70607058
languageName: node
70617059
linkType: hard
70627060

7063-
"mdast-util-directive@npm:3.0.0, mdast-util-directive@npm:^3.0.0":
7061+
"mdast-util-directive@npm:^3.0.0":
70647062
version: 3.0.0
70657063
resolution: "mdast-util-directive@npm:3.0.0"
70667064
dependencies:
@@ -7407,7 +7405,7 @@ __metadata:
74077405
languageName: node
74087406
linkType: hard
74097407

7410-
"micromark-extension-directive@npm:3.0.0, micromark-extension-directive@npm:^3.0.0":
7408+
"micromark-extension-directive@npm:^3.0.0":
74117409
version: 3.0.0
74127410
resolution: "micromark-extension-directive@npm:3.0.0"
74137411
dependencies:

0 commit comments

Comments
 (0)