Search

Cdaction

2 min read 0 views
Cdaction
`; // ---------- 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
  1. Creates a directory called cdaction-docs in the current working directory.
  2. Generates a full Docsify‑ready HTML file (index.html) that pulls the markdown from md and displays it.
  3. Creates a minimal sidebar (_sidebar.md) so Docsify can render a navigation menu.
  4. 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!
Was this helpful?

Share this article

See Also

Suggest a Correction

Found an error or have a suggestion? Let us know and we'll review it.

Comments (0)

Please sign in to leave a comment.

No comments yet. Be the first to comment!