How to use the jsdoc-to-markdown.getTemplateData function in jsdoc-to-markdown

To help you get started, we’ve selected a few jsdoc-to-markdown examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github discordjs / discord.js / docs / generator / index.js View on Github external
#!/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);
  }
github lando / lando / scripts / docs.js View on Github external
.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);
github electron-userland / electron-builder / scripts / jsdoc2md.js View on Github external
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({
github AgoraIO / Electron-SDK / scripts / jsapi.js View on Github external
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);
  });
});
github parro-it / libui-napi / tools / docs.js View on Github external
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}`);
github dhershman1 / kyanite / scripts / docs.js View on Github external
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)
  }))
github electron-userland / electron-builder / scripts / jsdoc2md.js View on Github external
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([
github DavidWells / analytics / scripts / docs / parse / parse.js View on Github external
async function getJSDocInfo(codePath) {
  const data = await jsdoc2md.getTemplateData({
    files: [ codePath ],
    json: true
  })
  return data
}

jsdoc-to-markdown

Generates markdown API documentation from jsdoc annotated source code

MIT
Latest version published 23 days ago

Package Health Score

76 / 100
Full package analysis