(part: RawJsDocPart)
| 502 | const describedLinkRegex = /{@link\s+(https?:\/\/[^\s|}]+)(?:\s*\|\s*([^}]*))?}/ |
| 503 | |
| 504 | const parseJsDocLink = (part: RawJsDocPart): ParsedJsDocPart => { |
| 505 | const linkText = part.getText() |
| 506 | const match = describedLinkRegex.exec(linkText) |
| 507 | if (match) { |
| 508 | const url = match[1].trim() |
| 509 | const value = match[2]?.trim() || url |
| 510 | return { kind: "link", url, value } |
| 511 | } |
| 512 | |
| 513 | const referencedName = part |
| 514 | .getChildren() |
| 515 | .find( |
| 516 | child => |
| 517 | child.isKind(SyntaxKind.Identifier) || |
| 518 | child.isKind(SyntaxKind.QualifiedName) |
| 519 | ) |
| 520 | ?.getText() |
| 521 | |
| 522 | if (!referencedName) { |
| 523 | return throwInternalError( |
| 524 | `Unable to parse referenced name from ${part.getText()}` |
| 525 | ) |
| 526 | } |
| 527 | |
| 528 | return { |
| 529 | kind: "reference", |
| 530 | value: referencedName |
| 531 | } |
| 532 | } |
| 533 | |
| 534 | type MatchContext = { |
| 535 | matchedJsDoc: JSDoc |
no test coverage detected