(part: RawJsDocPart)
| 249 | const describedLinkRegex = /{@link\s+(https?:\/\/[^\s|}]+)(?:\s*\|\s*([^}]*))?}/ |
| 250 | |
| 251 | const parseJsDocLink = (part: RawJsDocPart): ParsedJsDocPart => { |
| 252 | const linkText = part.getText() |
| 253 | const match = describedLinkRegex.exec(linkText) |
| 254 | if (match) { |
| 255 | const url = match[1].trim() |
| 256 | const value = match[2]?.trim() || url |
| 257 | return { kind: "link", url, value } |
| 258 | } |
| 259 | |
| 260 | const referencedName = part |
| 261 | .getChildren() |
| 262 | .find( |
| 263 | child => |
| 264 | child.isKind(SyntaxKind.Identifier) || |
| 265 | child.isKind(SyntaxKind.QualifiedName) |
| 266 | ) |
| 267 | ?.getText() |
| 268 | |
| 269 | if (!referencedName) { |
| 270 | return throwInternalError( |
| 271 | `Unable to parse referenced name from ${part.getText()}` |
| 272 | ) |
| 273 | } |
| 274 | |
| 275 | return { |
| 276 | kind: "reference", |
| 277 | value: referencedName |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | type MatchContext = { |
| 282 | matchedJsDoc: JSDoc |
no test coverage detected
searching dependent graphs…