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

Function parseBlock

ark/repo/jsdocGen.ts:395–450  ·  view source on GitHub ↗
(doc: JSDoc)

Source from the content-addressed store, hash-verified

393}
394
395const parseBlock = (doc: JSDoc): ParsedJsDocBlock | undefined => {
396 const nameAndGroup = extractNameAndGroup(doc)
397 if (!nameAndGroup) return undefined
398
399 const { name, group } = nameAndGroup
400
401 const tags = doc.getTags()
402 const rootComment = doc.getComment()
403
404 if (!rootComment)
405 return throwInternalError(`Expected root comment for ${group}/${name}`)
406
407 const allParts: ParsedJsDocPart[] =
408 typeof rootComment === "string" ?
409 parseJsDocText(rootComment)
410 : rootComment.filter(_ => !!_).flatMap(parseJsDocPart)
411
412 const { summary, notes } = organizeDocParts(allParts)
413 for (const note of notes) unmarkNote(note)
414
415 for (const tag of tags) {
416 if (tag.getTagName() !== "throws") continue
417 const thrown = /^@throws\s*{([^}]+)}([^*]*)/.exec(tag.getText())
418 if (thrown) {
419 notes.push([
420 {
421 kind: "noteStart",
422 value: `throws \`${thrown[1]}\` ${thrown[2].trim()}`.trim(),
423 warning: true
424 }
425 ])
426 }
427 }
428
429 const result: ParsedJsDocBlock = {
430 group,
431 name,
432 summary,
433 notes
434 }
435
436 const params = parametersOf(doc)
437 if (params) result.params = params
438
439 const example = tags.find(t => t.getTagName() === "example")?.getCommentText()
440 if (example) result.example = example
441
442 const experimentalTag = tags.find(t => t.getTagName() === "experimental")
443 if (experimentalTag) {
444 result.experimental = trimParts(
445 parseJsDocText(experimentalTag.getCommentText())
446 )
447 }
448
449 return result
450}
451
452/**

Callers 1

jsDocGenFunction · 0.85

Calls 11

extractNameAndGroupFunction · 0.85
throwInternalErrorFunction · 0.85
parseJsDocTextFunction · 0.85
organizeDocPartsFunction · 0.85
unmarkNoteFunction · 0.85
parametersOfFunction · 0.85
trimPartsFunction · 0.85
filterMethod · 0.80
execMethod · 0.80
findMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected