Skip to content

Commit 21dc1c7

Browse files
mbostockDuane Millar Barlow
and
Duane Millar Barlow
authored
allow jsdoc type declarations (#1110)
* allow jsdoc type declarations * prettier Co-authored-by: Duane Millar Barlow <[email protected]>
1 parent 386f07b commit 21dc1c7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

scripts/readme-to-jsdoc.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,17 @@ for (const file of glob.sync("build/**/*.js")) {
5454
let count = 0;
5555
for (let i = 0, n = lines.length; i < n; ++i) {
5656
let match: RegExpExecArray | null;
57-
if ((match = /^\/\*\*\s+@jsdoc\s+(\w+)\s+\*\/$/.exec(lines[i]))) {
58-
const [, name] = match;
57+
if ((match = /^(\s*(?:\/\*)?\*\s+)@jsdoc\s+(\w+)((?:\s*\*\/)?\s*)$/.exec(lines[i]))) {
58+
const [, pre, name, post] = match;
5959
const docs = docmap.get(name);
6060
if (!docs) throw new Error(`missing @jsdoc definition: ${name}`);
6161
if (!unused.has(name)) throw new Error(`duplicate @jsdoc reference: ${name}`);
6262
unused.delete(name);
6363
++count;
6464
lines[i] = docs
65-
.map((line, i, lines) => (i === 0 ? `/** ${line}` : i === lines.length - 1 ? ` * ${line}\n */` : ` * ${line}`))
65+
.map((line, i, lines) =>
66+
i === 0 ? `${pre}${line}` : i === lines.length - 1 ? ` * ${line}${post ? `\n${post}` : ""}` : ` * ${line}`
67+
)
6668
.join("\n");
6769
}
6870
}

0 commit comments

Comments
 (0)