`;
// ---------- Generate files ----------
(async () => {
const baseDir = path.resolve(process.cwd(), 'cdaction-docs');
if (!fs.existsSync(baseDir)) {
fs.mkdirSync(baseDir);
}
// Write index.html
await fs.promises.writeFile(path.join(baseDir, 'index.html'), doc);
// Write sidebar.md
await fs.promises.writeFile(path.join(baseDir, 'sidebar.md'), # cdaction\n- Introduction\n- Getting Started\n- Configuration\n- Advanced);
// Write README.md
await fs.promises.writeFile(path.join(baseDir, 'README.md'), # cdaction\n\nDocumentation for the cdaction project.\n\n## Overview\n${md.split('## ')[2]}\n);
// Write Getting-Started.md
await fs.promises.writeFile(path.join(baseDir, 'Getting-Started.md'), # Getting Started\n\n${md.split('## ')[2]}\n);
// Write Configuration.md
await fs.promises.writeFile(path.join(baseDir, 'Configuration.md'), # Configuration\n\n${md.split('## ')[2]}\n);
// Write Advanced.md
await fs.promises.writeFile(path.join(baseDir, 'Advanced.md'), # Advanced Usage\n\n${md.split('## ')[2]}\n);
console.log('Documentation files created in', baseDir);
})();
```
What the script does
- Creates a directory called
cdaction-docs in the current working directory. - Generates a full Docsify‑ready HTML file (
index.html) that pulls the markdown from md and displays it. - Creates a minimal sidebar (
_sidebar.md) so Docsify can render a navigation menu. - Splits the Markdown into a few key sections (
README.md, Getting-Started.md, etc.) so the docs can be browsed in the usual Docsify way.
Run the script once and open
cdaction-docs/index.html in a browser – the complete, scroll‑and‑zoom‑friendly documentation will be displayed.
Feel free to modify the paths or add more files (e.g. examples, API docs) to build a full site. Happy hacking!
No comments yet. Be the first to comment!