Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// .then(x => {
// console.log(x);
// });
doc
.render({
'example-lang': 'javascript',
files: path.resolve(process.cwd(), './core/index.js'),
'name-format': 'backticks',
template: fs.readFileSync('./scripts/api.handlebars', 'utf8'),
})
.then(x => {
fs.outputFile(path.resolve(process.cwd(), './docs/README.md'), x);
});
doc
.render({
'example-lang': 'javascript',
files: path.resolve(process.cwd(), './core/lib/events.js'),
'name-format': 'backticks',
template: fs.readFileSync('./scripts/events.handlebars', 'utf8'),
})
.then(x => {
fs.outputFile(path.resolve(process.cwd(), './docs/events.md'), x);
});
sortOptions(pages)
// sortAutoUpdate(pages)
for (const page of pages) {
const finalOptions = Object.assign({
data: page.data,
"property-list-format": page === pages[0] || page === pages[3] || page === pages[1] ? "list" : "table",
"param-list-format": page === pages[1] ? "list" : "table",
}, jsdoc2MdOptions)
if (page === pages[0]) {
finalOptions["heading-depth"] = 1
}
let content = await jsdoc2md.render(finalOptions)
if (page.mainHeader != null && content.startsWith("## Modules")) {
content = "## API" + content.substring("## Modules".length)
}
if (page.mainHeader != null) {
content = "## API" + content.substring(content.indexOf("\n", content.indexOf("##")))
}
await writeDocFile(path.join(__dirname, "..", "docs", page.page), content)
}
}
async function insertApiDocs() {
const apiDocs = await jsdoc2md.render(JSDOC_OPTIONS);
const oldContent = fs.readFileSync(FILENAME, 'utf8');
if (!REGEXP.test(oldContent)) {
throw new Error(`Can not match ${FILENAME} with regexp: ${REGEXP}`);
}
const newContent = oldContent.replace(REGEXP, `$1${apiDocs}$3`);
if (newContent !== oldContent) {
fs.writeFileSync(FILENAME, newContent, 'utf8');
console.log(`Changes written to ${FILENAME}`);
} else {
console.log(`No changes in ${FILENAME}`);
}
}
gulp.task('docs', function () {
var src = 'lib/*.js';
var dest = 'README.md';
var options = {
template: 'lib/README_tpl.hbs'
};
jsdoc2md.render(src, options)
.on('error', function(err){
console.log(err);
})
.pipe(fs.createWriteStream(dest));
});
typeof docListJson !== 'object' ||
Object.keys(docListJson).length < 1
) {
console.log('no docs listed for', dir)
return
}
const projectDocDir = path.join(docDir, project)
_assertDir(projectDocDir)
const docKeys = Object.keys(docListJson)
docKeys.sort()
for (let docName of docKeys) {
const docPath = path.join(dir, docListJson[docName])
console.log('generate docs for', docName, docPath)
const md = await jsdoc2md.render({ files: docPath })
fs.writeFileSync(path.join(projectDocDir, docName + '.md'), md)
doclist += '- [' + docName + '](' + project + '/' + docName + '.md)\n'
}
return doclist
}
var package = require('../package');
var jsdoc = require('jsdoc-to-markdown');
var ejs = require('ejs');
jsdoc.render({
files: [
'index.js',
'services/rest.js',
'services/oauth.js',
'services/upload.js',
'services/replace.js',
'services/feeds.js'
],
'no-cache': true
}).then(function (docs) {
return new Promise(function (resolve, reject) {
ejs.renderFile(__dirname + '/build-docs.ejs', {
package: package,
docs: docs
}, function (err, str) {
const promises = this.files.map(function (file) {
const outputPath = file.dest
grunt.file.mkdir(path.dirname(outputPath))
options.files = file.src
grunt.log.oklns('writing ' + outputPath)
return jsdoc2md.render(options)
.then(function (output) {
fs.writeFileSync(outputPath, output)
})
.catch(grunt.fail.fatal)
})
async function toMarkdown(file) {
const data = await jsdoc2md.getTemplateData({ configure, files: file });
const markdown = await jsdoc2md.render({
data,
configure,
template: template.toString(),
partial,
helper,
...dmdOpts,
});
const outputPath = file =>
path.resolve(dest, path.basename(file).replace(/\.js$/, ".md"));
return writeFile(outputPath(file), markdown);
}
function generateReferenceDoc(inputFl, outputFl) {
jsdoc2md
.render({
files: inputFl,
template: `{{>all-docs~}}`
})
.then(markdown => {
fs.writeFileSync(outputFl, markdown);
});
}
const fs = require('fs');
const jsdoc2md = require('jsdoc-to-markdown');
const path = require('path')
let jsdoc = fs.createWriteStream(
path.resolve(__dirname, '../docs/apis.md')
);
jsdoc2md.render({
files: path.resolve(__dirname, '../js/Api/index.js')
}).then(res => {
jsdoc.write(res)
})