How to use the jsdoc-to-markdown.renderSync 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 / index.js View on Github external
async function createMarkdownFromClasses(packageName, outputDir, api, readme) {
	console.log('createMarkdownFromClasses()')

	const { outputDocsDir, templateData } = setup(outputDir, true)

	// reduce templateData to an array of class names
	const classNames = templateData.reduce((classNames, identifier) => {
		if (identifier.kind === 'class') classNames.push(identifier.name)
		return classNames
	}, [])

	// create a documentation file for each class
	for (const className of classNames) {
		const template = `{{#class name="${className}"}}{{>docs}}{{/class}}`
		const output = jsdoc2md.renderSync({ data: templateData, template: template })
		fs.writeFileSync(path.resolve(outputDocsDir, `${className}.md`), output)
	}

	let apiOutput = await prepApi(api, templateData)

	apiOutput = mergeAndRepathHeaderLink(apiOutput, './')

	// use to convert links from page scroll to nav to other md files
	apiOutput = apiOutput.replace(/(\[)([^\]]+)(\]\(#([^\)]+)\))/g, (full, a, b, c, d) => {
		// split to see if it is a method or property
		const split = d.split('.')
		return split.length &gt; 1 ? `<a href="./docs/${split[0]}.md#${d}">${b}</a>` : b
	})

	combineAndWrite(packageName, outputDir, apiOutput, readme)
}
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 {
						// check 'd' for 'new_[name]_new' leading word
						split[0] = split[0].replace(/(new_)(.+)(_new)/, '$2')
					}
github apifytech / apify-js / website / tools / build_docs.js View on Github external
namespaces.forEach((name) => {
        const template = `{{#namespace name="${name}"}}{{>docs}}{{/namespace}}`;
        console.log(`Rendering ${name}, template: ${template}`); // eslint-disable-line no-console
        const output = jsdoc2md.renderSync(getRenderOptions(template, templateData));
        const markdown = generateFinalMarkdown(name, output);
        fs.writeFileSync(path.resolve(sourceFilesOutputDir, `${name}.md`), markdown);
    });
github ff0000-ad-tech / ad-docs / lib / index.js View on Github external
async function prepApi(api, templateData) {
	const apiData = await fs.readFileAsync(api)

	// create the main README
	return jsdoc2md.renderSync({
		data: templateData,
		template: apiData.toString(),
		helper: __dirname + '/helper.js'
	})
}
github approvals / Approvals.NodeJS / test / readmeTests.js View on Github external
it("Should not allow the readme docs to get out of sync", function () {

    var currentReadme = fs.readFileSync(path.join(__dirname, '../', 'readme.md')).toString()
    var cliDocsRaw = fs.readFileSync(path.join(__dirname, '../bin', 'help.md')).toString()

    cliDocsRaw = cliDocsRaw
      .replace(/&nbsp;/g, ' ')
      .replace(/\*\*/g, '');

    var approvalsSource = fs.readFileSync(path.join(__dirname, '../lib', 'Approvals.js')).toString();

    var jsdocsOutput = jsdoc2md.renderSync({ source: approvalsSource, 'no-cache': true})
    jsdocsOutput = jsdocsOutput.split('\n').map(function (line) {
      return line.replace(/\s+$/, '');
    }).join('\n');

    var newDocs = "";
    newDocs += "\n";
    newDocs += "\n";
    newDocs += "\n\n" + jsdocsOutput;
    newDocs += "\n\n";

    var cliDocs = "";
    cliDocs += "\n";
    cliDocs += "\n";
    cliDocs += "\n```";
    cliDocs += "\n\n" + cliDocsRaw;
    cliDocs += "\n```";
github codymurphyjones / NativeCore / package_scripts / jsdoc.js View on Github external
let generateMarkdown = (folder) => {
	let file = path.resolve(folder);
	
	try {
		var options = { files: file + '\\*.js'};
		console.log(options);
		let markdown = jsdoc2md.renderSync(options);
		console.log(markdown);
		return markdown;
	}
	catch(e) {
		//console.log(e);
		console.log("Error Caught");
	}
	
	return "";
}
github maykinmedia / dual-listbox / build / tasks / jsdoc.js View on Github external
files.forEach(file => {
            const fileinfo = path.parse(file.path);

            const vinylFile = new Vinyl({
                path: fileinfo.name + '.md',
                contents: new Buffer.from(jsdoc2md.renderSync({files: file.path}))
            });
            stream.push(vinylFile);
        });
        cb();
github iuap-design / kero / gulpfile.js View on Github external
function produceAPI(sourceArr, rsPath) {
    var apidocsPath = path.join(envPath, 'docs');
    const output = jsdoc2md.renderSync({ files: sourceArr })
    var isexist = fs.existsSync(apidocsPath);
    if (!isexist) {
        fs.mkdirSync(apidocsPath);
    }
    fs.writeFileSync(path.join(apidocsPath, rsPath), output)
}

jsdoc-to-markdown

Generates markdown API documentation from jsdoc annotated source code

MIT
Latest version published 3 months ago

Package Health Score

67 / 100
Full package analysis