Skip to content

Instantly share code, notes, and snippets.

@thepassle
Last active February 16, 2021 19:32
Show Gist options
  • Save thepassle/163f100a310695134656dbe2aeea75a8 to your computer and use it in GitHub Desktop.
Save thepassle/163f100a310695134656dbe2aeea75a8 to your computer and use it in GitHub Desktop.
Generate README files for generic-components as a custom-elements-manifest plugin
import path from 'path';
import fs from 'fs';
import { customElementsManifestToMarkdown } from '../custom-elements-json-to-markdown/index.js';
function generateReadme() {
const components = ['generic-disclosure', 'generic-switch'];
const fauxCEM = {"modules": [{"declarations": []}];
return {
packageLinkPhase(cem) {
const classDocForComponents = [];
cem.modules.forEach(mod => {
mod.declarations.forEach(declaration => {
if(components.includes(declaration.tagName)) {
fauxCEM.modules[0].path = declaration.tagName;
fauxCEM.modules[0].declarations = [declaration];
fs.writeFileSync(
`${path.dirname(mod.path)}/README.md`,
customElementsManifestToMarkdown(fauxCEM)
);
}
});
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment