-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate jsdoc-to-markdown as a build-docs command.
- Loading branch information
Showing
5 changed files
with
613 additions
and
6 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict'; | ||
|
||
const jsdocToMd = require('jsdoc-to-markdown'); | ||
const path = require('path'); | ||
const { $ } = require('zx'); | ||
const { readFile, writeFile } = require('fs').promises; | ||
|
||
const { loadConfig } = require('../utils'); | ||
|
||
module.exports = { | ||
command: path.parse(__filename).name, | ||
describe: 'Builds the README.md file from the JSDoc in the codebase.', | ||
handler: async () => { | ||
$.verbose = false; | ||
const cwd = process.cwd(); | ||
const readmePath = path.resolve(cwd, 'README.md'); | ||
const { docs } = await loadConfig(); | ||
const { files, headingDepth, noGfm, template } = docs || {}; | ||
const templatePath = template || path.resolve(cwd, 'docs', 'templates', 'README.hbs'); | ||
const templateData = await readFile(templatePath, 'utf8'); | ||
const cfg = { | ||
files: (Array.isArray(files) && files) || ['./lib/**/*.js'], | ||
'heading-depth': headingDepth ?? 2, | ||
'no-gfm': noGfm ?? false, | ||
template: templateData | ||
}; | ||
const output = await jsdocToMd.render(cfg); | ||
await writeFile(readmePath, output, 'utf8'); | ||
await $`git add ./README.md`; | ||
} | ||
}; |
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
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
Oops, something went wrong.