@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>
30 lines • 1.31 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDemoAssets = getDemoAssets;
const builder_1 = require("@ng-doc/builder");
const build_file_assets_1 = require("../build-file-assets");
const remove_lines_from_code_1 = require("../remove-lines-from-code");
const snippets_from_asset_1 = require("../snippets-from-asset");
const get_component_source_files_1 = require("./get-component-source-files");
/**
* Creates an array of assets from a component source file.
* @param cls - The class declaration.
* @param inlineStyleLanguage
*/
function getDemoAssets(cls, inlineStyleLanguage) {
const assets = (0, get_component_source_files_1.getComponentSourceFiles)(cls)
.map((filePath) => (0, build_file_assets_1.buildFileAsset)(filePath))
.map((asset) => {
const snippets = (0, snippets_from_asset_1.snippetsFromAsset)(asset, inlineStyleLanguage);
return snippets.length ? snippets : [asset];
})
.flat()
.map((asset) => ({
...asset,
code: (0, builder_1.renderTemplate)('./code.html.nunj', {
context: { code: (0, remove_lines_from_code_1.removeLinesFromCode)(asset.code), lang: asset.lang || 'ts' },
}).trim(),
}));
return assets;
}
//# sourceMappingURL=get-component-assets.js.map
;