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

Function sourceFileTopLevelJSDoc

packages/tools/jsdocs/src/Jsdocs.ts:3294–3311  ·  view source on GitHub ↗
(sourceFile: ts.SourceFile)

Source from the content-addressed store, hash-verified

3292}
3293
3294function sourceFileTopLevelJSDoc(sourceFile: ts.SourceFile): ParsedModuleJSDoc | undefined {
3295 const source = sourceFile.text
3296 const start = skipLeadingIgnoredTrivia(source)
3297 if (!source.startsWith("/**", start)) return undefined
3298 const end = source.indexOf("*/", start + 3)
3299 if (end === -1) return undefined
3300 const range = [start, end + 2] as const
3301 const firstStatement = sourceFile.statements[0]
3302 if (firstStatement !== undefined) {
3303 const jsDocs = (firstStatement as { readonly jsDoc?: ReadonlyArray<ts.JSDoc> }).jsDoc ?? []
3304 if (
3305 jsDocs.some((jsDoc) => jsDoc.pos === range[0] && jsDoc.end === range[1]) &&
3306 !ts.isImportDeclaration(firstStatement) &&
3307 !ts.isImportEqualsDeclaration(firstStatement)
3308 ) return undefined
3309 }
3310 return { raw: source.slice(range[0], range[1]), range }
3311}
3312
3313function parseModuleJSDocTs(
3314 sourceFile: ts.SourceFile,

Callers 1

parseSourceFileDocsFunction · 0.85

Calls 3

skipLeadingIgnoredTriviaFunction · 0.85
someMethod · 0.80
sliceMethod · 0.80

Tested by

no test coverage detected