You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
863 B

const GfmEscape = require('gfm-escape');
const nunjucks = require('nunjucks');
const path = require('path');
const mdEscaper = new GfmEscape();
const mdCodeEscaper = new GfmEscape({}, 'codeSpan');
const mdLinkTitleEscaper = new GfmEscape({}, 'linkTitle');
nunjucks
.configure(path.join(__dirname, 'templates'), {
autoescape: false,
noCache: true,
trimBlocks: true
})
.addFilter('md', str => mdEscaper.escape(str))
.addFilter('mdCode', str => mdCodeEscaper.escape(str))
.addFilter('mdLinkTitle', str => mdLinkTitleEscaper.escape(str));
const generateAllCmdsDoc = (cmds) => {
for (const [cmdName, cmd] of Object.entries(cmds)) {
cmd.options = cmd.options?.split(' ');
//cmd.desc = cmd.desc?.split(/ *\n */).join(' ');
}
return nunjucks.render('doc-all.md', { cmds });
};
exports.generateAllCmdsDoc = generateAllCmdsDoc;