Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#!/usr/bin/env node
/* eslint-disable no-console */
const fs = require('fs');
const jsdoc2md = require('jsdoc-to-markdown');
const Documentation = require('./documentation');
const custom = require('../custom/index');
const config = require('./config');
process.on('unhandledRejection', console.error);
console.log(`Using format version ${config.GEN_VERSION}.`);
console.log('Parsing JSDocs in source files...');
jsdoc2md.getTemplateData({ files: [`./src/*.js`, `./src/**/*.js`] }).then(data => {
console.log(`${data.length} items found.`);
const documentation = new Documentation(data, custom);
console.log('Serializing...');
let output = JSON.stringify(documentation.serialize(), null, 0);
if (config.compress) {
console.log('Compressing...');
output = require('zlib').deflateSync(output).toString('utf8');
}
if (!process.argv.slice(2).includes('test')) {
console.log('Writing to docs.json...');
fs.writeFileSync('./docs/docs.json', output);
}
.each(section => {
return jsdoc2md.getTemplateData({'files': docs.sections[section], 'no-cache': true})
// Fix "aliases" and then render
.then(data => _.map(data, datum => util.fixAlias(datum)))
// Do the render
.then(data => jsdoc2md.render({
'data': data,
'global-index-format': 'none',
'helper': docs.helpers,
'partial': docs.partials,
}))
// Report and collect errors
.catch(error => {
errors.push(error.message);
log.error('ERROR: %', error.message);
async function render(pages, jsdoc2MdOptions) {
require(path.join(__dirname, "jsdoc", "helpers.js")).pages = pages
for (const page of pages) {
page.data = await jsdoc2md.getTemplateData(Object.assign({
files: pathSorter(page.files).map(it => path.resolve(source, it)),
}, jsdoc2MdOptions))
const map = new Map()
for (const member of page.data) {
map.set(member.id, member)
}
page.dataMap = map
}
sortOptions(pages)
// sortAutoUpdate(pages)
for (const page of pages) {
const finalOptions = Object.assign({
const fs = require('fs')
const jsdoc2md = require('jsdoc-to-markdown')
const path = require('path')
const jsDocWriteStream = fs.createWriteStream(
path.resolve(__dirname, '../docs/apis.md')
);
const getData = jsdoc2md.getTemplateData({
files: path.resolve(__dirname, '../js/Api/index.js')
});
// generate js api doc
getData.then(res => {
jsdoc2md.render({
data: res
}).then(res => {
jsDocWriteStream.write(res);
});
});
async function render([mainClass, input]) {
const data = await jsdoc2md.getTemplateData({files: input});
const mainClassData =
data.sort((i1, i2) => i1.order - i2.order)
.filter(item => item.memberof === mainClass || item.id === mainClass)
.map((item, idx) => ({...item, order: idx}));
if (mainClassData.length <= 1) {
throw new Error(`No data found for class ${mainClass} in files ${input}`);
}
const output = 'docs/' + toDotCase(mainClass.slice(2)).replace(/\./g, '-') + '.md';
const d = await jsdoc2md.render({
data: mainClassData,
partial: 'tools/docs/header.hbs',
helper: 'tools/docs/hbs_helper.js'
});
await fs.promises.writeFile(output, d);
console.log(`${mainClass} -> ${output}`);
title: 'Browser',
code: ``
}
})
const generateSyntax = (fnName, args) => {
if (!args) {
return ''
}
const argsStr = args.map(a => a.optional ? `[${a.name}]` : a.name).join(', ')
return `${fnName}(${argsStr})`
}
jsDocParser.getTemplateData({
'files': listFns(),
'no-cache': true
}).then((data) => {
const results = data.map(d => ({
since: d.since ? d.since : 'Unknown',
deprecated: d.deprecated || false,
category: d.category || 'Uncategorized',
title: d.name,
desc: d.description,
examples: d.examples,
returns: d.returns,
params: d.params,
syntax: generateSyntax(d.name, d.params),
usage: generateUsage(d.name)
}))
async function render2(files, jsdoc2MdOptions) {
const data = await jsdoc2md.getTemplateData(Object.assign({
files: pathSorter(files).map(it => path.resolve(source, it)),
}, jsdoc2MdOptions))
const dataMap = new Map()
for (const member of data) {
if (member.name.endsWith("MetadataDirectories") || isInlinedMember(member)) {
member.inlined = true
}
dataMap.set(member.id, member)
}
const { Renderer, TypeNamePlace, Page } = require("./renderer/out/main")
const renderer = new Renderer(dataMap)
const blockedPropertyName = new Set([
async function getJSDocInfo(codePath) {
const data = await jsdoc2md.getTemplateData({
files: [ codePath ],
json: true
})
return data
}