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

Function sourceFileTopLevelJSDoc

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

Source from the content-addressed store, hash-verified

3222}
3223
3224function sourceFileTopLevelJSDoc(sourceFile: ts.SourceFile): ParsedModuleJSDoc | undefined {
3225 const source = sourceFile.text
3226 const start = skipLeadingIgnoredTrivia(source)
3227 if (!source.startsWith("/**", start)) return undefined
3228 const end = source.indexOf("*/", start + 3)
3229 if (end === -1) return undefined
3230 const range = [start, end + 2] as const
3231 const firstStatement = sourceFile.statements[0]
3232 if (firstStatement !== undefined) {
3233 const jsDocs = (firstStatement as { readonly jsDoc?: ReadonlyArray<ts.JSDoc> }).jsDoc ?? []
3234 if (
3235 jsDocs.some((jsDoc) => jsDoc.pos === range[0] && jsDoc.end === range[1]) &&
3236 !ts.isImportDeclaration(firstStatement) &&
3237 !ts.isImportEqualsDeclaration(firstStatement)
3238 ) return undefined
3239 }
3240 return { raw: source.slice(range[0], range[1]), range }
3241}
3242
3243function parseModuleJSDocTs(
3244 sourceFile: ts.SourceFile,

Callers 1

parseSourceFileDocsFunction · 0.85

Calls 2

skipLeadingIgnoredTriviaFunction · 0.85
someMethod · 0.80

Tested by

no test coverage detected