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

Function readJSDocModel

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

Source from the content-addressed store, hash-verified

3575 * @since 4.0.0
3576 */
3577export function readJSDocModel(filename: string): Result<JSDocModel, string> {
3578 if (!fs.existsSync(filename)) return { _tag: "Failure", error: "missing" }
3579 try {
3580 const parsed = JSON.parse(fs.readFileSync(filename, "utf8")) as JSDocModel
3581 if (parsed.version !== 3) return { _tag: "Failure", error: "Unsupported jsdocs model version" }
3582 if (!Array.isArray(parsed.files)) return { _tag: "Failure", error: "Invalid jsdocs model: files must be an array" }
3583 if (!Array.isArray(parsed.apis)) return { _tag: "Failure", error: "Invalid jsdocs model: apis must be an array" }
3584 return { _tag: "Success", value: parsed }
3585 } catch (error) {
3586 return { _tag: "Failure", error: `Invalid jsdocs model: ${error instanceof Error ? error.message : String(error)}` }
3587 }
3588}
3589
3590/**
3591 * Computes the content hash stored for a source file in a JSDoc model.

Callers 1

bin.tsFile · 0.90

Calls 2

StringFunction · 0.50
parseMethod · 0.45

Tested by

no test coverage detected