MCPcopy Create free account
hub / github.com/arktypeio/arktype / parseJsDocLink

Function parseJsDocLink

ark/repo/jsdocGen.ts:504–532  ·  view source on GitHub ↗
(part: RawJsDocPart)

Source from the content-addressed store, hash-verified

502const describedLinkRegex = /{@link\s+(https?:\/\/[^\s|}]+)(?:\s*\|\s*([^}]*))?}/
503
504const 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
534type MatchContext = {
535 matchedJsDoc: JSDoc

Callers 1

parseJsDocPartFunction · 0.85

Calls 3

throwInternalErrorFunction · 0.85
execMethod · 0.80
findMethod · 0.80

Tested by

no test coverage detected