| 61 | * @internal |
| 62 | */ |
| 63 | export const parseComment = (text: string): Comment => { |
| 64 | const annotation: doctrine.Annotation = doctrine.parse(text, { |
| 65 | unwrap: true |
| 66 | }) |
| 67 | |
| 68 | const description = pipe( |
| 69 | Option.fromNullishOr(annotation.description), |
| 70 | Option.map((s) => s.trim()), |
| 71 | Option.filter(String.isNonEmpty), |
| 72 | Option.getOrUndefined |
| 73 | ) |
| 74 | |
| 75 | const tags = pipe( |
| 76 | annotation.tags, |
| 77 | Array.groupBy((tag) => tag.title), |
| 78 | Record.map((values) => |
| 79 | Array.map(values, (tag) => |
| 80 | pipe( |
| 81 | Option.fromNullishOr(tag.description), |
| 82 | Option.map(String.trim), |
| 83 | Option.getOrElse(() => "") |
| 84 | )) |
| 85 | ) |
| 86 | ) |
| 87 | |
| 88 | return { description, tags } |
| 89 | } |
| 90 | |
| 91 | const isVariableDeclarationList = ( |
| 92 | u: ast.VariableDeclarationList | ast.CatchClause |