diff --git a/src/utils/util.ts b/src/utils/util.ts index 521006c22106..9431aa3a8cc8 100644 --- a/src/utils/util.ts +++ b/src/utils/util.ts @@ -86,10 +86,16 @@ export function addDocBlock(str: string, docs?: d.CompilerJsDoc, indentation: nu return str; } - return [getDocBlock(docs, indentation), str].filter(Boolean).join(`\n`); + return [formatDocBlock(docs, indentation), str].filter(Boolean).join(`\n`); } -function getDocBlock(docs: d.CompilerJsDoc, indentation: number = 0): string { +/** + * Formats the given compiled docs to a JavaScript doc block + * @param docs the compiled JS docs + * @param indentation number of spaces to indent the block with + * @returns the formatted doc block + */ +function formatDocBlock(docs: d.CompilerJsDoc, indentation: number = 0): string { const textDocs = getDocBlockLines(docs); if (!textDocs.filter(Boolean).length) { return ''; @@ -100,6 +106,11 @@ function getDocBlock(docs: d.CompilerJsDoc, indentation: number = 0): string { return [spaces + '/**', ...textDocs.map((line) => spaces + ` * ${line}`), spaces + ' */'].join(`\n`); } +/** + * Get all lines part of the doc block + * @param docs the compiled JS docs + * @returns list of lines part of the doc block + */ function getDocBlockLines(docs: d.CompilerJsDoc): string[] { return [ ...docs.text.split(lineBreakRegex),