Last active
February 16, 2021 19:32
-
-
Save thepassle/163f100a310695134656dbe2aeea75a8 to your computer and use it in GitHub Desktop.
Generate README files for generic-components as a custom-elements-manifest plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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