Skip to content

Commit f01cef9

Browse files
committed
docs: update description extractor
1 parent 808b384 commit f01cef9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

packages/metadata/scripts/update.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ function getCategory(ts: string) {
2727

2828
function getDescription(ts: string) {
2929
const commentBlock = ts.slice(ts.lastIndexOf('\n/**\n') + 1)
30-
const s = commentBlock?.match(/^ \* (.+)$/m)?.[1].trim()
31-
return s?.startsWith('@') ? undefined : s
30+
const lines = commentBlock.split('\n')
31+
.filter(line => line.startsWith(' * '))
32+
.map(line => line.slice(3))
33+
.filter(line => !line.startsWith('@reactive') && !line.startsWith('@category'))
34+
return lines.join('\n')
3235
}
3336

3437
function toCategoryName(api: string) {
@@ -43,7 +46,7 @@ async function getComposableMetadata(filename: string): Promise<FunctionMetadata
4346
const _md = existsSync(mdPath) ? await fs.readFile(mdPath, 'utf-8') : undefined // TODO: md
4447
const original = getOriginalAPI(ts)
4548
const category = getCategory(ts) ?? (original ? toCategoryName(original) : undefined)
46-
const description = getDescription(ts) ?? (original ? `Reactive API for \`vscode::${original}\`.` : undefined)
49+
const description = getDescription(ts) || (original ? `Reactive API for \`vscode::${original}\`.` : undefined)
4750
return {
4851
name,
4952
category,

0 commit comments

Comments
 (0)