UNPKG

bit-bin

Version:

<a href="https://opensource.org/licenses/Apache-2.0"><img alt="apache" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a> <a href="https://github.com/teambit/bit/blob/master/CONTRIBUTING.md"><img alt="prs" src="https://img.shields.io/b

29 lines (23 loc) 831 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.docsTemplate = docsTemplate; function docsData(component) { var _component$state$stor; return ((_component$state$stor = component.state.store.findExtension('@teambit/docs')) === null || _component$state$stor === void 0 ? void 0 : _component$state$stor.data) || {}; } function toIdentifier(name) { return name.replace('/', '$'); } function docsTemplate(components) { const withDocs = components.filter(component => docsData(component).filepath); return `import { addDocs } from '../docs'; ${withDocs.map(component => { return `import ${toIdentifier(component.id.name)} from '${docsData(component).filepath}';\n`; }).join('')} addDocs([ ${withDocs.map(component => `${toIdentifier(component.id.name)},\n`).join('')} ]); `; }