function getComments()

in src/directives.ts [64:97]


function getComments(tag: ts.JSDocTag): Comment[] {
  if (tag.comment == null) {
    return [];
  }

  if (typeof tag.comment === 'string') {
    const text = tag.comment.trim();
    return text
      ? text.split(/[\n,]/).flatMap((line) => {
          line = line.trim();
          return line ? [{ text: line, jsdocNode: tag }] : [];
        })
      : [];
  }

  // Possible per the type signature in the compiler, however not sure in which conditions.
  return tag.comment.flatMap((jsdocNode): Comment[] => {
    let text: string;
    switch (jsdocNode.kind) {
      case ts.SyntaxKind.JSDocText:
        text = jsdocNode.text;
        break;
      case ts.SyntaxKind.JSDocLink:
      case ts.SyntaxKind.JSDocLinkCode:
      case ts.SyntaxKind.JSDocLinkPlain:
        text = jsdocNode.name
          ? `${jsdocNode.name.getText(jsdocNode.name.getSourceFile())}: ${jsdocNode.text}`
          : jsdocNode.text;
        break;
    }
    text = text.trim();
    return text ? [{ text, jsdocNode }] : [];
  });
}