How to use jsdoc - 10 common examples

To help you get started, we’ve selected a few jsdoc 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 WhitestormJS / whs.js / docs / template / publish.js View on Github external
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(
github almende / vis / docs / publish.js View on Github external
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');
  });
github HumanBrainProject / jsdoc-sphinx / template / publish.js View on Github external
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.
github deebloo / generator-angular-blueprint / generators / app / templates / ES6 / doc / template / publish.js View on Github external
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 = [];
github OpenGeoscience / geojs / jsdoc / template / publish.js View on Github external
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, '
github Aymkdn / SharepointPlus / jsdoc_template / publish.js View on Github external
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;
github Sjeiti / TinySort / _oldrem / jsdoc / template / publish.js View on Github external
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' );
}
github xperiments / TSDoc / template / publish.js View on Github external
{
					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
		};
github davidshimjs / jaguarjs-jsdoc / publish.js View on Github external
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),
github SuperMap / iClient-JavaScript / build / jsdocs / template / publish.js View on Github external
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
            });