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>

42 lines 1.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.API_LIST_BUILDER_TAG = void 0; exports.apiListBuilder = apiListBuilder; 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"); const core_2 = require("../../core"); exports.API_LIST_BUILDER_TAG = 'ApiList'; /** * * @param config */ function apiListBuilder(config) { const { context, metadata, data } = config; return (0, rxjs_1.of)(void 0).pipe((0, core_2.runBuild)(exports.API_LIST_BUILDER_TAG, async () => ({ filePath: path_1.default.join(...(0, core_1.asArray)(context.outAssetsDir, metadata.entry.route, 'api-list.json')), content: JSON.stringify(buildApiList(data), undefined, 2), }))); } /** * * @param context * @param data */ function buildApiList(data) { const uniqScopes = data.reduce((lists, [scope, metadata]) => { lists.set(scope, (lists.get(scope) ?? []).concat([metadata])); return lists; }, new Map()); return Array.from(uniqScopes.entries()).map(([scope, items]) => ({ title: scope.name, items: items.map((metadata) => ({ route: `/${metadata.absoluteRoute()}`, type: (0, helpers_1.getKindType)(metadata.entry.declaration) ?? '', name: metadata.entry.declaration.getName() ?? '[Unknown]', })), })); } //# sourceMappingURL=api-list.builder.js.map