Skip to content

Commit b4b8ae2

Browse files
committed
Refactor JSDoc generation in rollup-types-fixup.mjs to improve readability and maintainability. Streamlined the mapping of standard material properties and enhanced the cleaning of type descriptions for better documentation output.
1 parent 60e72f0 commit b4b8ae2

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

utils/plugins/rollup-types-fixup.mjs

+16-16
Original file line numberDiff line numberDiff line change
@@ -195,24 +195,24 @@ const REPLACEMENTS = [{
195195

196196
// Find the jsdoc block description using eg "@property {Type} {name}"
197197
return contents.replace('reset(): void;', `reset(): void;
198-
${STANDARD_MAT_PROPS.map(prop => {
199-
const typeDefinition = `@property {${prop[1]}} ${prop[0]}`
200-
const typeDescriptionIndex = contents.match(typeDefinition);
201-
const typeDescription = typeDescriptionIndex ?
202-
contents.slice(typeDescriptionIndex.index + typeDefinition.length, contents.indexOf('\n * @property', typeDescriptionIndex.index + typeDefinition.length))
203-
: '';
198+
${STANDARD_MAT_PROPS.map((prop) => {
199+
const typeDefinition = `@property {${prop[1]}} ${prop[0]}`;
200+
const typeDescriptionIndex = contents.match(typeDefinition);
201+
const typeDescription = typeDescriptionIndex ?
202+
contents.slice(typeDescriptionIndex.index + typeDefinition.length, contents.indexOf('\n * @property', typeDescriptionIndex.index + typeDefinition.length)) :
203+
'';
204204
205-
// Strip newlines, asterisks, and tabs from the type description
206-
const cleanTypeDescription = typeDescription
207-
.trim()
208-
.replace(/[\n\t*]/g, ' ') // remove newlines, tabs, and asterisks
209-
.replace(/\s+/g, ' '); // collapse whitespace
205+
// Strip newlines, asterisks, and tabs from the type description
206+
const cleanTypeDescription = typeDescription
207+
.trim()
208+
.replace(/[\n\t*]/g, ' ') // remove newlines, tabs, and asterisks
209+
.replace(/\s+/g, ' '); // collapse whitespace
210210
211-
const jsdoc = cleanTypeDescription ? `/** ${cleanTypeDescription} */` : '';
212-
// console.log(prop[0], contents.match(`@property {${prop[1]}} ${prop[0]}`), cleanTypeDescription);
213-
return `\t${jsdoc}\n\tset ${prop[0]}(arg: ${prop[1]});\n\tget ${prop[0]}(): ${prop[1]};\n\n`;
214-
}).join('')}`,
215-
)
211+
const jsdoc = cleanTypeDescription ? `/** ${cleanTypeDescription} */` : '';
212+
// console.log(prop[0], contents.match(`@property {${prop[1]}} ${prop[0]}`), cleanTypeDescription);
213+
return `\t${jsdoc}\n\tset ${prop[0]}(arg: ${prop[1]});\n\tget ${prop[0]}(): ${prop[1]};\n\n`;
214+
}).join('')}`
215+
);
216216
},
217217
footer: `
218218
import { Color } from '../../core/math/color.js';

0 commit comments

Comments
 (0)