@storm-stack/core
Version:
A build toolkit and runtime used by Storm Software in TypeScript applications
77 lines (71 loc) • 3.23 kB
JavaScript
;
var chunk3ONWID2V_cjs = require('./chunk-3ONWID2V.cjs');
var types = require('@storm-software/config-tools/types');
var helpers = require('@stryke/fs/helpers');
var exists = require('@stryke/path/exists');
var joinPaths = require('@stryke/path/join-paths');
var typedoc = require('typedoc');
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
var typedoc__default = /*#__PURE__*/_interopDefault(typedoc);
async function docsApiReference(context, hooks) {
context.log(types.LogLevelLabel.TRACE, "Writing API-Reference documentation for the Storm Stack project artifacts.");
const outputPath = joinPaths.joinPaths(context.options.projectRoot, "docs", "generated", "api-reference");
if (exists.existsSync(outputPath)) {
await helpers.removeDirectory(outputPath);
}
await helpers.createDirectory(outputPath);
const app = await typedoc__default.default.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.joinPaths(context.options.projectRoot, entry.file)),
tsconfig: context.options.tsconfig,
exclude: context.tsconfig?.raw?.exclude,
out: outputPath
}, [
new typedoc__default.default.TypeDocReader(),
new typedoc__default.default.PackageJsonReader(),
new typedoc__default.default.TSConfigReader()
]);
const project = await app.convert();
if (project) {
await app.generateDocs(project, outputPath);
}
await hooks.callHook("docs:api-reference", context).catch((error) => {
context.log(types.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
});
});
}
chunk3ONWID2V_cjs.__name(docsApiReference, "docsApiReference");
// src/commands/docs/index.ts
async function docs(context, hooks) {
await hooks.callHook("docs:begin", context).catch((error) => {
context.log(types.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(types.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
});
});
}
chunk3ONWID2V_cjs.__name(docs, "docs");
exports.docs = docs;
//# sourceMappingURL=chunk-U7VT5A6F.cjs.map
//# sourceMappingURL=chunk-U7VT5A6F.cjs.map