@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>
67 lines • 2.78 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.API_BUILDER_TAG = exports.API_PAGE_TEMPLATE_BUILDER_TAG = void 0;
exports.apiPageTemplateBuilder = apiPageTemplateBuilder;
const core_1 = require("@ng-doc/core");
const rxjs_1 = require("rxjs");
const ts_morph_1 = require("ts-morph");
const core_2 = require("../../core");
const nunjucks_1 = require("../../nunjucks");
const shared_1 = require("../shared");
const build_api_keywords_1 = require("./keywords/build-api-keywords");
exports.API_PAGE_TEMPLATE_BUILDER_TAG = 'ApiPageTemplate';
exports.API_BUILDER_TAG = 'Api';
/**
*
* @param config
*/
function apiPageTemplateBuilder(config) {
const { context, metadata, tabMetadata, scope } = config;
const { entry: { declaration }, } = metadata;
const declPath = declaration.getSourceFile().getFilePath();
const pageKey = `${declPath}#${declaration.getName()}`;
const cacheStrategy = {
id: `${pageKey}#ApiTemplate`,
action: 'skip',
files: () => [tabMetadata.outPath],
};
core_2.PageStore.add([pageKey, metadata]);
return (0, shared_1.pageComponentBuilder)((postProcess) => (0, core_2.factory)(exports.API_PAGE_TEMPLATE_BUILDER_TAG, [
(0, shared_1.contentBuilder)({
tag: exports.API_BUILDER_TAG,
context,
mainFilePath: declPath,
cacheId: `${declPath}#Api`,
metadata: tabMetadata,
getKeywords: (0, build_api_keywords_1.buildApiKeywords)(metadata),
getContent: async () => {
await metadata.refresh();
// refreshed declaration
const declaration = metadata.entry.declaration;
return (0, nunjucks_1.renderTemplate)('./api-page-content.html.nunj', {
context: {
declaration,
docNode: ts_morph_1.Node.isVariableDeclaration(declaration)
? declaration.getVariableStatement()
: declaration,
templateName: (0, core_1.kebabCase)(declaration.getKindName()),
scope,
},
});
},
}),
], async (content) => {
return {
metadata: tabMetadata,
output: postProcess(content),
};
}, cacheStrategy), {
context,
metadata: tabMetadata,
pageType: 'api',
lineNumber: declaration.getStartLineNumber(),
}).pipe((0, rxjs_1.takeUntil)((0, rxjs_1.merge)((0, core_2.watchFile)(declPath, 'delete'), metadata.selfDestroy)), (0, rxjs_1.finalize)(() => {
core_2.PageStore.delete(pageKey);
}));
}
//# sourceMappingURL=api-page-template.builder.js.map
;