MCPcopy Create free account
hub / github.com/Effect-TS/effect / parseDocumentedTs

Function parseDocumentedTs

packages/tools/jsdocs/src/Jsdocs.ts:2762–2809  ·  view source on GitHub ↗
(
  node: ts.Node,
  scope: DocScope,
  diagnostics: Array<JSDocModelDiagnostic>,
  required = true,
  linkContext?: { readonly checker: ts.TypeChecker; readonly entry: ProgramCacheEntry; readonly cwd: string }
)

Source from the content-addressed store, hash-verified

2760}
2761
2762function parseDocumentedTs(
2763 node: ts.Node,
2764 scope: DocScope,
2765 diagnostics: Array<JSDocModelDiagnostic>,
2766 required = true,
2767 linkContext?: { readonly checker: ts.TypeChecker; readonly entry: ProgramCacheEntry; readonly cwd: string }
2768) {
2769 let block = getNodeJSDoc(node)
2770 // Barrel re-exports intentionally use minimal, tag-only JSDoc.
2771 if (block !== undefined && (ts.isExportDeclaration(node) || ts.isExportSpecifier(node))) {
2772 const loose = parseLooseJSDocBlock(block.raw, block.range)
2773 if (loose.tags[0]?.line === 0) {
2774 block = {
2775 ...loose,
2776 parsed: {
2777 description: { short: "", whenToUse: null, details: null, gotchas: null },
2778 examples: [],
2779 tags: loose.tags
2780 }
2781 }
2782 }
2783 }
2784 if (block?.internal) return undefined
2785 if (block === undefined) {
2786 if (required) {
2787 diagnostics.push({
2788 ...diagnostic("missing-jsdoc", scope === "member" ? "Member JSDoc is required" : "Public JSDoc is required"),
2789 range: nodeRange(node)
2790 })
2791 }
2792 return undefined
2793 }
2794 addModelDiagnostics(diagnostics, block.range, block.diagnostics)
2795 if (block.parsed === undefined) return undefined
2796 // Only names that can be imported directly require @stability.
2797 const requireStability = scope === "declaration" || (scope === "namespace" && ts.isSourceFile(node.parent))
2798 const tags = buildTags(scope, block.parsed.tags, requireStability)
2799 if (tags._tag === "Failure") {
2800 addModelDiagnostics(diagnostics, block.range, tags.error.diagnostics)
2801 return undefined
2802 }
2803 const parsedTags = tags.value as ParsedDeclarationTags | ParsedNamespaceTags | ParsedMemberTags
2804 if (linkContext !== undefined) addJSDocLinkDiagnostics(node.getSourceFile(), block, diagnostics, linkContext)
2805 return {
2806 core: block.parsed,
2807 tags: linkContext === undefined ? parsedTags : attachSeeLinkSymbols(parsedTags, node, block, linkContext)
2808 }
2809}
2810
2811function hasExportModifier(node: ts.Node): boolean {
2812 return ts.canHaveModifiers(node) &&

Callers 3

parseTsMembersFunction · 0.85
parseNamespaceTsFunction · 0.85
parseSourceFileDocsFunction · 0.85

Calls 9

getNodeJSDocFunction · 0.85
parseLooseJSDocBlockFunction · 0.85
diagnosticFunction · 0.85
nodeRangeFunction · 0.85
addModelDiagnosticsFunction · 0.85
buildTagsFunction · 0.85
addJSDocLinkDiagnosticsFunction · 0.85
attachSeeLinkSymbolsFunction · 0.85
pushMethod · 0.65

Tested by

no test coverage detected