How to use the jsdoc-to-markdown.getTemplateDataSync 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 ff0000-ad-tech / ad-docs / lib / doc_master_nav.js View on Github external
fs.readFile(obj.api, (err, apiData) => {
				if (err) reject(err)
				console.log(obj.name)
				// console.log(obj.files)
				const templateData = jsdoc2md.getTemplateDataSync({ files: obj.files, configure: docUtils.CONFIG_PATH })
				// console.log(templateData)

				let output = jsdoc2md.renderSync({
					data: templateData,
					template: apiData.toString(),
					helper: __dirname + '/helper.js'
				})

				// remap the links
				output = output.replace(/(\[)([^\]]+)(\]\(#([^\)]+)\))/g, (full, a, b, c, d) => {
					// split to see if it is a method or property
					const split = d.split('.')
					let subPath = ''
					if (split.length > 1) {
						subPath = `#${d}`
					} else {
github typicode / react-lodash / generate / index.js View on Github external
function getDocs() {
  // Get all lodash functions
  const functionNames = _.functions(_)
  console.log(`Found ${functionNames.length} functions`)

  // Find all files associated to lodash functions
  const files = functionNames
    .map(functionName =>
      path.join(__dirname, `../node_modules/lodash/${functionName}.js`)
    )
    .filter(fs.existsSync)
  console.log(`Found ${files.length} files`)

  // Parse JSDoc for each file
  const docs = jsdoc2md
    .getTemplateDataSync({ files })
    .filter(doc => functionNames.includes(doc.name))
  console.log(`Found ${docs.length} docs`)

  return docs
}
github ff0000-ad-tech / ad-docs / lib / index.js View on Github external
function setup(outputDir, createDocsDir) {
	// input and output paths
	const inputFiles = [outputDir + 'index.js'].concat(docUtils.readDirRecursive(outputDir + 'lib'))

	// get template data
	const templateData = jsdoc2md.getTemplateDataSync({ files: inputFiles, configure: docUtils.CONFIG_PATH })

	if (createDocsDir) {
		const outputDocsDir = outputDir + 'docs'
		if (!fs.existsSync(outputDocsDir)) {
			fs.mkdirSync(outputDocsDir)
		}
		return { outputDocsDir, templateData }
	}

	return templateData
}
github twitch-js / twitch-js / scripts / generateDocs / index.js View on Github external
const createTemplate = ({ kind, title, sidebarLabel }) => `---
id: ${kind}
title: ${title}
sidebar_label: ${sidebarLabel}
---

{{>global-index-kinds kind="${kind}" ~}}

{{#identifiers kind="${kind}" scope="global"}}
{{>docs~}}
{{/identifiers}}
`

// Get template data.
const templateData = jsdoc2md.getTemplateDataSync({
  files: inputFile,
})

// Group template data by kind.
const templateDataByKind = groupBy(templateData, 'kind')

const tasks = new Listr(
  // Create a documentation file for each kind.
  Object.keys(templateDataByKind).map(kind => {
    const title = titleMap[kind]

    const template = createTemplate({
      kind,
      title,
      sidebarLabel: titleMap[kind],
    })
github seznam / IMA.js-core / gulp / doc.js View on Github external
map((file, callback) => {
        let urlPrefix = '';
        let menuHandled = false;
        let templateData = jsdoc2md.getTemplateDataSync({ files: file.path });
        let textHandled = false;
        const filename = file.relative
          .replace(/(\/|.jsx|.js)/g, '')
          .replace(/([a-zA-Z])(?=[A-Z])/g, '$1-')
          .toLowerCase();

        templateData = templateData.map(item => {
          if (item.meta) {
            const { filename = '', lineno = 0, path = '' } = item.meta;

            item.imaGitUrl = `${gitUrl}${path
              .split(DOC_SRC)
              .pop()}/${filename}#L${lineno}`;

            if (!menuHandled) {
              const category = path.split(`${DOC_SRC}/`);
github marnusw / date-fns-tz / scripts / build / docs.js View on Github external
fn =>
        jsDocParser.getTemplateDataSync({
          files: fn.fullPath,
          'no-cache': true
        })[0]
    )
github wix / react-native-navigation / scripts / generate-js-doc.js View on Github external
const generateMarkdownForFile = ({ file, outputDir, partial, separator }) => {
  const templateData = jsdoc2md.getTemplateDataSync({ files: file });
  const classNames = getClassesInFile(templateData);
  classNames.forEach((className) => createDocFileForClass({ className, templateData, outputDir, partial, separator }));
};
github MassiveHeights / Black / scripts / docs.js View on Github external
genParams(item) {
    let text = '';
    for (let i = 0; i < item.params.length; i++) {
      let element = item.params[i];

      text += element.name;

      if (i != item.params.length - 1)
        text += ', ';

    }
    return text;
  }
}

const templateData = jsdoc2md.getTemplateDataSync({
  files: inputFile
});

let g = new Generator();
g.setTemplateData(templateData)

function ensureDirectoryExistence(filePath) {
  let dirname = path.dirname(filePath);
  if (fs.existsSync(dirname)) {
    return true;
  }
  ensureDirectoryExistence(dirname);
  fs.mkdirSync(dirname);
}

const classNames = [];
github tecfu / tty-table / Gruntfile.js View on Github external
encoding : "utf-8"
    });  
    
    //Inject example usage into README
    var example1 = fs.readFileSync('./examples/styles-and-formatting.js',{
      encoding : 'utf-8'
    });
    example1 = example1.replace('../','tty-table');
    example1 = '\n```js\n' + example1 + '\n```';  
    readme = readme.replace(
      /((?:.|[\r\n])*)/m,
      '\n'+example1+'\n'
    );
  
    const jsdoc2md = require('jsdoc-to-markdown');
    let jsdocData = jsdoc2md.getTemplateDataSync({
      //configure: __dirname + '/conf.json', //jsdoc config file path
      files: 'src/*.js'
    });
    let stdout = jsdoc2md.renderSync({
      data: jsdocData,
      "no-usage-stats": true
    });

    //Reformat documentation to reflect correct method naming.
    var str = stdout.replace(/new /g,'').replace(/_public\./g,'');

    readme = readme.replace(
      /((?:.|[\r\n])*)/m,
      '\n\n'+str+'\n'
    );

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