UNPKG

@storm-stack/core

Version:

A build toolkit and runtime used by Storm Software in TypeScript applications

71 lines (68 loc) 2.92 kB
import { __name } from './chunk-43IZMM3W.js'; import { LogLevelLabel } from '@storm-software/config-tools/types'; import { removeDirectory, createDirectory } from '@stryke/fs/helpers'; import { existsSync } from '@stryke/path/exists'; import { joinPaths } from '@stryke/path/join-paths'; import typedoc from 'typedoc'; async function docsApiReference(context, hooks) { context.log(LogLevelLabel.TRACE, "Writing API-Reference documentation for the Storm Stack project artifacts."); const outputPath = joinPaths(context.options.projectRoot, "docs", "generated", "api-reference"); if (existsSync(outputPath)) { await removeDirectory(outputPath); } await createDirectory(outputPath); const app = await typedoc.Application.bootstrapWithPlugins({ plugin: [ "typedoc-plugin-markdown", "typedoc-plugin-frontmatter", "@storm-stack/core/lib/typedoc" ], theme: "storm-stack", hideGenerator: true, readme: "none", excludePrivate: true, gitRevision: context.options.branch || "main", entryPoints: context.entry.map((entry) => joinPaths(context.options.projectRoot, entry.file)), tsconfig: context.options.tsconfig, exclude: context.tsconfig?.raw?.exclude, out: outputPath }, [ new typedoc.TypeDocReader(), new typedoc.PackageJsonReader(), new typedoc.TSConfigReader() ]); const project = await app.convert(); if (project) { await app.generateDocs(project, outputPath); } await hooks.callHook("docs:api-reference", context).catch((error) => { context.log(LogLevelLabel.ERROR, `An error occured while writing the API-Reference documentation for the Storm Stack project artifacts: ${error.message} ${error.stack ?? ""}`); throw new Error("An error occured while writing the API-Reference documentation for the Storm Stack project artifacts", { cause: error }); }); } __name(docsApiReference, "docsApiReference"); // src/commands/docs/index.ts async function docs(context, hooks) { await hooks.callHook("docs:begin", context).catch((error) => { context.log(LogLevelLabel.ERROR, `An error occured while starting to generate documentation for the Storm Stack project: ${error.message} ${error.stack ?? ""}`); throw new Error("An error occured while starting to generate documentation for the Storm Stack project", { cause: error }); }); await docsApiReference(context, hooks); await hooks.callHook("docs:complete", context).catch((error) => { context.log(LogLevelLabel.ERROR, `An error occured while finishing generation of documentation for the Storm Stack project: ${error.message} ${error.stack ?? ""}`); throw new Error("An error occured while finishing generation of documentation for the Storm Stack project", { cause: error }); }); } __name(docs, "docs"); export { docs }; //# sourceMappingURL=chunk-4I46RBIP.js.map //# sourceMappingURL=chunk-4I46RBIP.js.map