Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'jsdoc' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
exports.publish = function(taffyData, opts, tutorials) {
data = taffyData
var conf = env.conf.templates || {}
conf.default = conf.default || {}
var templatePath = path.normalize(opts.template)
view = new template.Template(path.join(templatePath, "tmpl"))
// claim some special filenames in advance, so the All-Powerful Overseer of Filename Uniqueness
// doesn't try to hand them out later
// var indexUrl = helper.getUniqueFilename("index")
// don't call registerLink() on this one! 'index' is also a valid longname
var globalUrl = helper.getUniqueFilename("global")
helper.registerLink("global", globalUrl)
// set up templating
view.layout = conf.default.layoutFile
? path.getResourcePath(
if (/publish.js$/.test(fileName)) return; // Skip self
if (/README.md$/.test(fileName)) return; // Skip own README
if (/\.tmpl$/.test(fileName)) return; // Skip .tmpl files; these are used as partials only
if (!/\.html$/.test(fileName)) {
// Just plain copy over non-html files
var tmpDir = fs.toDir(outFile);
fs.mkPath(tmpDir);
fs.copyFileSync(fileName, tmpDir);
return;
}
// Render html files as templates
//console.log(relName);
var html = renderer.partial(relName, {});
fs.mkPath(fs.toDir(outFile));
fs.writeFileSync(outFile, html, 'utf8');
});
doclet.signature += ')';
_.each(doclet.returns, function(r) {
if (!(r && r.type && r.type.names)) {
logger.debug('Bad return', r, doclet.longname);
return;
}
r.signature = ':return ' +
r.type && r.type.names && r.type.names.join('|');
});
}
// build the list of page generation actions.
var actions = [];
actions.push(generate(
helper.getUniqueFilename('index'), require('./view-models/home')));
actions.push(generate(
'conf.py', require('./view-models/sphinx-config')));
var docletModel = require('./view-models/doclet');
context.data().each(function(doclet) {
var url = helper.longnameToUrl[doclet.longname];
if (url.indexOf('#') !== -1) {
logger.debug('URL Generator', url, doclet.longname);
url = helper.longnameToUrl[doclet.longname].split(/#/).pop();
logger.debug('URL Generated', url);
}
if (util.mainDocletKinds.indexOf(doclet.kind) !== -1) {
actions.push(generate(url, docletModel(doclet)));
}
});
// publish must be synchronous as the caller does not care about callbacks.
data = taffyData;
var conf = env.conf.templates || {};
conf['default'] = conf['default'] || {};
var templatePath = opts.template;
view = new template.Template(templatePath + '/tmpl');
console.log('view', view);
// claim some special filenames in advance, so the All-Powerful Overseer of Filename Uniqueness
// doesn't try to hand them out later
var indexUrl = helper.getUniqueFilename('index');
// don't call registerLink() on this one! 'index' is also a valid longname
var globalUrl = helper.getUniqueFilename('global');
helper.registerLink('global', globalUrl);
// set up templating
view.layout = conf['default'].layoutFile ?
path.getResourcePath(path.dirname(conf['default'].layoutFile),
path.basename(conf['default'].layoutFile) ) :
'layout.tmpl';
// set up tutorials for helper
helper.setTutorials(tutorials);
data = helper.prune(data);
data.sort('longname, version, since');
helper.addEventListeners(data);
var sourceFiles = {};
var sourceFilePaths = [];
function generate(title, docs, filename, resolveLinks) {
resolveLinks = resolveLinks === false ? false : true;
var docData = {
filename: filename,
title: title,
docs: docs
};
var outpath = path.join(outdir, filename),
html = view.render('container.tmpl', docData);
if (resolveLinks) {
html = helper.resolveLinks(html); // turn {@link foo} into <a href="foodoc.html">foo</a>
// Add a link target for external links @davidshimjs
html = html.toString().replace(/]*href\s*=\s*['"]*[^\s'"]*:\/\/)/ig, '
if (doclet.meta) {
sourcePath = getPathFromDoclet(doclet);
sourceFiles[sourcePath] = {
resolved: sourcePath,
shortened: null
};
if (sourceFilePaths.indexOf(sourcePath) === -1) {
sourceFilePaths.push(sourcePath);
}
}
});
// update outdir if necessary, then create outdir
var packageInfo = ( find({kind: 'package'}) || [] ) [0];
if (packageInfo && packageInfo.name) {
outdir = path.join( outdir, packageInfo.name, (packageInfo.version || '') );
}
fs.mkPath(outdir);
// copy the template's static files to outdir
var fromDir = path.join(templatePath, 'static');
var staticFiles = fs.ls(fromDir, 3);
staticFiles.forEach(function(fileName) {
var toDir = fs.toDir( fileName.replace(fromDir, outdir) );
fs.mkPath(toDir);
fs.copyFileSync(fileName, toDir);
});
// copy user-specified static files to outdir
var staticFilePaths;
var staticFileFilter;
function generate( docType, title, docs, filename, resolveLinks ) {
resolveLinks = resolveLinks === false ? false : true;
var docData = {
title : title,
docs : docs,
docType : docType
};
var outpath = path.join( outdir, filename ),
html = view.render( 'container.tmpl', docData );//+JSON.stringify(docData);
if ( resolveLinks ) {
html = helper.resolveLinks( html ); // turn {@link foo} into <a href="foodoc.html">foo</a>
}
fs.writeFileSync( outpath, html, 'utf8' );
}
{
if( namesNS.indexOf( myNamespaces[ns].longname)==-1 )
{
outNS.push( myNamespaces[ns]);
namesNS.push( myNamespaces[ns].longname );
}
}
generate( 'namespace', 'Namespace: ' + outNS[0].longname, outNS, helper.longnameToUrl[longname] );
}
var myMixins = helper.find( mixins, {longname : longname} );
if ( myMixins.length ) {
generate( 'mixin', 'Mixin: ' + myMixins[0].name, myMixins, helper.longnameToUrl[longname] );
}
var myExternals = helper.find( externals, {longname : longname} );
if ( myExternals.length ) {
generate( 'external', 'External: ' + myExternals[0].name, myExternals, helper.longnameToUrl[longname] );
}
}
}
// TODO: move the tutorial functions to templateHelper.js
function generateTutorial( title, tutorial, filename ) {
var tutorialData = {
title : title,
header : tutorial.title,
content : tutorial.parse(),
children : tutorial.children,
docs : null
};
var myModules = helper.find(modules, {longname: longname});
if (myModules.length) {
generate('Module: ' + myModules[0].name, myModules, helper.longnameToUrl[longname]);
}
var myNamespaces = helper.find(namespaces, {longname: longname});
if (myNamespaces.length) {
generate('Namespace: ' + myNamespaces[0].name, myNamespaces, helper.longnameToUrl[longname]);
}
var myMixins = helper.find(mixins, {longname: longname});
if (myMixins.length) {
generate('Mixin: ' + myMixins[0].name, myMixins, helper.longnameToUrl[longname]);
}
var myExternals = helper.find(externals, {longname: longname});
if (myExternals.length) {
generate('External: ' + myExternals[0].name, myExternals, helper.longnameToUrl[longname]);
}
}
}
// TODO: move the tutorial functions to templateHelper.js
function generateTutorial(title, tutorial, filename) {
var tutorialData = {
title: title,
header: tutorial.title,
content: tutorial.parse(),
children: tutorial.children
};
var tutorialPath = path.join(outdir, filename),
kind: 'mainpage',
readme: opts.readme,
longname: (opts.mainpagetitle) ? opts.mainpagetitle : 'Main Page'
}].concat(files),
indexUrl);
// set up the lists that we'll use to generate pages
var classes = taffy(members.classes);
var modules = taffy(members.modules);
var namespaces = taffy(members.namespaces);
var mixins = taffy(members.mixins);
var externals = taffy(members.externals);
for (var longname in helper.longnameToUrl) {
if (hasOwnProp.call(helper.longnameToUrl, longname)) {
var myClasses = helper.find(classes, {
longname: longname
});
if (myClasses.length) {
generate('Class: ' + myClasses[0].name, myClasses, helper.longnameToUrl[longname]);
}
var myModules = helper.find(modules, {
longname: longname
});
if (myModules.length) {
generate('Module: ' + myModules[0].name, myModules, helper.longnameToUrl[longname]);
}
var myNamespaces = helper.find(namespaces, {
longname: longname
});