(doc: JSDoc)
| 393 | } |
| 394 | |
| 395 | const 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 | /** |
no test coverage detected