From 3233c63548e4da623a504db1da438b5560a64f67 Mon Sep 17 00:00:00 2001 From: Mike Bostock Date: Wed, 23 Nov 2022 10:21:46 -0500 Subject: [PATCH 1/2] allow jsdoc type declarations --- scripts/readme-to-jsdoc.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/readme-to-jsdoc.ts b/scripts/readme-to-jsdoc.ts index 7b3dda6e9f..f49fe5aee6 100755 --- a/scripts/readme-to-jsdoc.ts +++ b/scripts/readme-to-jsdoc.ts @@ -54,15 +54,15 @@ for (const file of glob.sync("build/**/*.js")) { let count = 0; for (let i = 0, n = lines.length; i < n; ++i) { let match: RegExpExecArray | null; - if ((match = /^\/\*\*\s+@jsdoc\s+(\w+)\s+\*\/$/.exec(lines[i]))) { - const [, name] = match; + if ((match = /^(\s*(?:\/\*)?\*\s+)@jsdoc\s+(\w+)((?:\s*\*\/)?\s*)$/.exec(lines[i]))) { + const [, pre, name, post] = match; const docs = docmap.get(name); if (!docs) throw new Error(`missing @jsdoc definition: ${name}`); if (!unused.has(name)) throw new Error(`duplicate @jsdoc reference: ${name}`); unused.delete(name); ++count; lines[i] = docs - .map((line, i, lines) => (i === 0 ? `/** ${line}` : i === lines.length - 1 ? ` * ${line}\n */` : ` * ${line}`)) + .map((line, i, lines) => (i === 0 ? `${pre}${line}` : i === lines.length - 1 ? ` * ${line}${post ? `\n${post}` : ""}` : ` * ${line}`)) .join("\n"); } } From fae6ba4506b4b6e8eb100bf51e68b597fb9c211e Mon Sep 17 00:00:00 2001 From: Duane Millar Barlow Date: Wed, 23 Nov 2022 11:08:01 -0500 Subject: [PATCH 2/2] prettier --- scripts/readme-to-jsdoc.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/readme-to-jsdoc.ts b/scripts/readme-to-jsdoc.ts index f49fe5aee6..5c48440de5 100755 --- a/scripts/readme-to-jsdoc.ts +++ b/scripts/readme-to-jsdoc.ts @@ -62,7 +62,9 @@ for (const file of glob.sync("build/**/*.js")) { unused.delete(name); ++count; lines[i] = docs - .map((line, i, lines) => (i === 0 ? `${pre}${line}` : i === lines.length - 1 ? ` * ${line}${post ? `\n${post}` : ""}` : ` * ${line}`)) + .map((line, i, lines) => + i === 0 ? `${pre}${line}` : i === lines.length - 1 ? ` * ${line}${post ? `\n${post}` : ""}` : ` * ${line}` + ) .join("\n"); } }