MCPcopy
hub / github.com/arktypeio/arktype / parseJsDocLink

Function parseJsDocLink

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

Source from the content-addressed store, hash-verified

249const describedLinkRegex = /{@link\s+(https?:\/\/[^\s|}]+)(?:\s*\|\s*([^}]*))?}/
250
251const 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
281type MatchContext = {
282 matchedJsDoc: JSDoc

Callers 1

parseJsDocPartFunction · 0.85

Calls 2

throwInternalErrorFunction · 0.85
execMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…