Skip to content

Commit

Permalink
Improve README.md template
Browse files Browse the repository at this point in the history
  • Loading branch information
etrepum committed Apr 15, 2024
1 parent d94ebb1 commit 37c078e
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions scripts/update-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,41 @@ sidebar_label: '${npmName}'
);
}

function readmeTemplate(npmName) {
function readmeTemplate(npmName, directoryName, description) {
const apiModuleName = directoryName.replace(/-/g, '_');
return (
`
# \`${npmName}\`
[![See API Documentation](https://lexical.dev/img/see-api-documentation.svg)](https://lexical.dev/docs/api/modules/lexical_devtools_core)
[![See API Documentation](https://lexical.dev/img/see-api-documentation.svg)](https://lexical.dev/docs/api/modules/${apiModuleName})
TODO: This package needs a description!
${description}
`.trim() + '\n'
);
}

function updateDocs() {
packagesManager.getPublicPackages().forEach((pkg) => {
const npmName = pkg.getNpmName();
const directoryName = pkg.getDirectoryName();
const root = pkg.resolve('..', '..');
const readmePath = pkg.resolve('README.md');
const sidebarPath = webPkg.resolve(
'docs',
'packages',
`${pkg.getDirectoryName()}.md`,
`${directoryName}.md`,
);
if (!fs.existsSync(readmePath)) {
console.log(`Creating ${path.relative(root, readmePath)}`);
fs.writeFileSync(readmePath, readmeTemplate(npmName));
fs.writeFileSync(
readmePath,
readmeTemplate(
npmName,
directoryName,
pkg.packageJson.description ||
'TODO: This package needs a description!',
),
);
}
if (!fs.existsSync(sidebarPath)) {
console.log(`Creating ${path.relative(root, sidebarPath)}`);
Expand Down

0 comments on commit 37c078e

Please sign in to comment.