UNPKG

@ng-doc/builder

Version:

<!-- PROJECT LOGO --> <br /> <div align="center"> <a href="https://github.com/ng-doc/ng-doc"> <img src="https://ng-doc.com/assets/images/ng-doc.svg?raw=true" alt="Logo" height="150px"> </a>

58 lines 2.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createDeclarationMetadata = createDeclarationMetadata; const tslib_1 = require("tslib"); const core_1 = require("@ng-doc/core"); const path_1 = tslib_1.__importDefault(require("path")); const rxjs_1 = require("rxjs"); const helpers_1 = require("../../../helpers"); /** * * @param context * @param declaration * @param entry * @param scope */ function createDeclarationMetadata(context, declaration, entry, scope) { const declarationName = declaration.getName() ?? '[Unknown]'; const sourceFile = declaration.getSourceFile(); const dir = sourceFile.getDirectoryPath(); const dirName = path_1.default.basename(dir); const route = (0, helpers_1.posix)(path_1.default.join(...(0, core_1.asArray)(entry.route ?? 'api', (0, helpers_1.declarationFolderName)(declaration), scope.route, declaration.getName()))); const outDir = path_1.default.join(context.outApiDir, route); const selfDestroy = new rxjs_1.Subject(); return { ...entry, dir, dirName, path: sourceFile.getFilePath(), route, outDir, // Having parent as undefined will force rendering list of routes flat parent: undefined, outPath: path_1.default.join(outDir, 'page.ts'), title: declarationName, keywordTitle: declarationName, sourceFile, breadcrumbs: function () { return [entry.title, scope.name, this.title]; }, refresh: async function () { await sourceFile.refreshFromFileSystem(); const newDeclaration = sourceFile.getExportedDeclarations().get(declarationName)?.[0]; if (!newDeclaration || !(0, helpers_1.isSupportedDeclaration)(newDeclaration)) { selfDestroy.next(); } else { this.entry.declaration = newDeclaration; } }, selfDestroy, hidden: true, entry: { declaration, scope, }, }; } //# sourceMappingURL=create-declaration-metadata.js.map