Skip to content

Instantly share code, notes, and snippets.

@Kinjalrk2k
Created January 23, 2022 10:06
Show Gist options
  • Save Kinjalrk2k/d47601ce91c27815cbc9e1971637e7ac to your computer and use it in GitHub Desktop.
Save Kinjalrk2k/d47601ce91c27815cbc9e1971637e7ac to your computer and use it in GitHub Desktop.
JsDoc to Markdown with folder structure
const jsdoc2md = require("jsdoc-to-markdown");
const fs = require("fs");
const path = require("path");
// const dirs = fs.readdirSync(path.resolve("."));
// console.log(dirs);
const glob = require("glob");
glob("**/*.js", { ignore: "node_modules/*/**" }, async (err, files) => {
console.log(files);
await Promise.all(
files.map(async (file) => {
const output = await jsdoc2md.render({ files: file });
console.log(path.dirname(file));
fs.mkdirSync(`docs/jsdoc/${path.dirname(file)}`, { recursive: true });
fs.writeFileSync(`docs/jsdoc/${file}.md`, output, { flag: "a+" });
})
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment