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

Function readJSDocModel

packages/tools/jsdocs/src/Jsdocs.ts:3487–3498  ·  view source on GitHub ↗
(filename: string)

Source from the content-addressed store, hash-verified

3485 * @since 4.0.0
3486 */
3487export function readJSDocModel(filename: string): Result<JSDocModel, string> {
3488 if (!fs.existsSync(filename)) return { _tag: "Failure", error: "missing" }
3489 try {
3490 const parsed = JSON.parse(fs.readFileSync(filename, "utf8")) as JSDocModel
3491 if (parsed.version !== 2) return { _tag: "Failure", error: "Unsupported jsdocs model version" }
3492 if (!Array.isArray(parsed.files)) return { _tag: "Failure", error: "Invalid jsdocs model: files must be an array" }
3493 if (!Array.isArray(parsed.apis)) return { _tag: "Failure", error: "Invalid jsdocs model: apis must be an array" }
3494 return { _tag: "Success", value: parsed }
3495 } catch (error) {
3496 return { _tag: "Failure", error: `Invalid jsdocs model: ${error instanceof Error ? error.message : String(error)}` }
3497 }
3498}
3499
3500/**
3501 * Computes the content hash stored for a source file in a JSDoc model.

Callers 1

bin.tsFile · 0.90

Calls 2

StringInterface · 0.50
parseMethod · 0.45

Tested by

no test coverage detected