From 877c9d19ae3b0039403411ad150bd6cf93cbd969 Mon Sep 17 00:00:00 2001
From: William Wall
' + reqSnippet;
+ }
+ doclet.description = description;
+ }
+ return doclet;
+}
+
+/**
+ * Iterates over all doclets and finds the names of types that contain
+ * undefined. Stores the names in the global variable undefinedLikes, so
+ * that e.g. markRequiredIfNeeded can use these.
+ */
+function findTypesLikeUndefined(doclets) {
+ undefinedLikes = ['undefined']; // include type 'undefined' explicitly
+ for (var i = doclets.length - 1; i >= 0; --i) {
+ var doclet = doclets[i];
+ if(doclet.kind === 'typedef') {
+ var types = doclet.type.names;
+ if (types.indexOf('undefined') !== -1) {
+ // the typedef contains 'undefined', so it self is undefinedLike.
+ undefinedLikes.push(doclet.longname);
+ }
+ }
+ }
+}
+
+exports.handlers = {
+
+ newDoclet: function(e) {
+ var doclet = e.doclet;
+ if (doclet.meta.filename == 'olx.js') {
+ if (doclet.kind == 'typedef') {
+ lastOlxTypedef = doclet;
+ olxTypeNames.push(doclet.longname);
+ olxTypes[doclet.longname] = [];
+ doclet.properties = [];
+ } else if (lastOlxTypedef && doclet.memberof == lastOlxTypedef.longname) {
+ lastOlxTypedef.properties.push(doclet);
+ olxTypes[lastOlxTypedef.longname].push(doclet);
+ } else {
+ lastOlxTypedef = null;
+ }
+ } else if (doclet.isEnum) {
+ // We never export enums, so we document them like typedefs
+ doclet.kind = 'typedef';
+ delete doclet.isEnum;
+ }
+ },
+
+ parseComplete: function(e) {
+ var doclets = e.doclets;
+ findTypesLikeUndefined(doclets);
+ for (var i = doclets.length - 1; i >= 0; --i) {
+ var doclet = doclets[i];
+ var params = doclet.params;
+ if (params) {
+ addSubparams(params);
+ }
+ markRequiredIfNeeded(doclet);
+ }
+ }
+
+};
diff --git a/jsdoc/template/publish.js b/jsdoc/template/publish.js
new file mode 100644
index 0000000..68a60ea
--- /dev/null
+++ b/jsdoc/template/publish.js
@@ -0,0 +1,516 @@
+/*global env: true */
+var template = require('jsdoc/template'),
+ fs = require('jsdoc/fs'),
+ path = require('jsdoc/path'),
+ taffy = require('taffydb').taffy,
+ handle = require('jsdoc/util/error').handle,
+ helper = require('jsdoc/util/templateHelper'),
+ _ = require('underscore'),
+ htmlsafe = helper.htmlsafe,
+ linkto = helper.linkto,
+ resolveAuthorLinks = helper.resolveAuthorLinks,
+ scopeToPunc = helper.scopeToPunc,
+ hasOwnProp = Object.prototype.hasOwnProperty,
+ data,
+ view,
+ outdir = env.opts.destination;
+
+function find(spec) {
+ return helper.find(data, spec);
+}
+
+function tutoriallink(tutorial) {
+ return helper.toTutorial(tutorial, null, { tag: 'em', classname: 'disabled', prefix: 'Tutorial: ' });
+}
+
+function getAncestorLinks(doclet) {
+ return helper.getAncestorLinks(data, doclet);
+}
+
+function hashToLink(doclet, hash) {
+ if ( !/^(#.+)/.test(hash) ) { return hash; }
+
+ var url = helper.createLink(doclet);
+
+ url = url.replace(/(#.+|$)/, hash);
+ return '' + hash + '';
+}
+
+function needsSignature(doclet) {
+ var needsSig = false;
+
+ // function and class definitions always get a signature
+ if (doclet.kind === 'function' || doclet.kind === 'class') {
+ needsSig = true;
+ }
+ // typedefs that contain functions get a signature, too
+ else if (doclet.kind === 'typedef' && doclet.type && doclet.type.names &&
+ doclet.type.names.length) {
+ for (var i = 0, l = doclet.type.names.length; i < l; i++) {
+ if (doclet.type.names[i].toLowerCase() === 'function') {
+ needsSig = true;
+ break;
+ }
+ }
+ }
+
+ return needsSig;
+}
+
+function addSignatureParams(f) {
+ var params = helper.getSignatureParams(f, 'optional');
+
+ f.signature = (f.signature || '') + '('+params.join(', ')+')';
+}
+
+function addSignatureReturns(f) {
+ var returnTypes = helper.getSignatureReturns(f);
+
+ f.signature = ''+(f.signature || '') + '';
+
+ if (returnTypes.length) {
+ f.signature += ''+(returnTypes.length ? '{'+returnTypes.join('|')+'}' : '')+'';
+ }
+}
+
+function addSignatureTypes(f) {
+ var types = helper.getSignatureTypes(f);
+
+ f.signature = (f.signature || '') + ''+(types.length? ' :'+types.join('|') : '')+'';
+}
+
+function addAttribs(f) {
+ var attribs = helper.getAttribs(f);
+
+ if (attribs.length) {
+ f.attribs = '' + htmlsafe(attribs.length ? attribs.join(',') : '') + '';
+ }
+}
+
+function shortenPaths(files, commonPrefix) {
+ // always use forward slashes
+ var regexp = new RegExp('\\\\', 'g');
+
+ Object.keys(files).forEach(function(file) {
+ files[file].shortened = files[file].resolved.replace(commonPrefix, '')
+ .replace(regexp, '/');
+ });
+
+ return files;
+}
+
+function resolveSourcePath(filepath) {
+ return path.resolve(process.cwd(), filepath);
+}
+
+function getPathFromDoclet(doclet) {
+ if (!doclet.meta) {
+ return;
+ }
+
+ var filepath = doclet.meta.path && doclet.meta.path !== 'null' ?
+ doclet.meta.path + '/' + doclet.meta.filename :
+ doclet.meta.filename;
+
+ return filepath;
+}
+
+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 foo
+
+ // Add a link target for external links @davidshimjs
+ html = html.toString().replace(/]*href\s*=\s*['"]*[^\s'"]*:\/\/)/ig, '} doclets - The array of classes and functions to
+ * check.
+ * @param {Array.