mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Merge pull request #140 from hegemonic/ce287745f15f420ec31006e6435e4b4505bca0ee
Make JSDoc JSHint-clean (part 2)
This commit is contained in:
commit
4ead9aa4f9
18
.jshintrc
18
.jshintrc
@ -1,19 +1,19 @@
|
||||
{
|
||||
"bitwise": false,
|
||||
"curly": false,
|
||||
"bitwise": true,
|
||||
"curly": true,
|
||||
"eqeqeq": false,
|
||||
"forin": false,
|
||||
"immed": false,
|
||||
"forin": true,
|
||||
"immed": true,
|
||||
"latedef": false,
|
||||
"newcap": false,
|
||||
"noarg": false,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"noempty": false,
|
||||
"nonew": false,
|
||||
"nonew": true,
|
||||
"plusplus": false,
|
||||
"regexp": false,
|
||||
"undef": false,
|
||||
"undef": true,
|
||||
"strict": false,
|
||||
"trailing": false,
|
||||
"trailing": true,
|
||||
|
||||
"asi": true,
|
||||
"boss": true,
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
/*global desc: true, fail: true, Mustache: true, task: true */
|
||||
// see: https://github.com/mde/jake
|
||||
|
||||
desc('Updating package.json revision.');
|
||||
|
||||
16
jsdoc.js
16
jsdoc.js
@ -1,3 +1,4 @@
|
||||
/*global app: true, args: true, env: true, publish: true */
|
||||
/**
|
||||
* @project jsdoc
|
||||
* @author Michael Mathews <micmath@gmail.com>
|
||||
@ -8,6 +9,8 @@
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
|
||||
|
||||
var hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
|
||||
/** Data representing the environment in which this app is running.
|
||||
@namespace
|
||||
*/
|
||||
@ -30,7 +33,7 @@ env = {
|
||||
*/
|
||||
conf: {},
|
||||
|
||||
/**
|
||||
/**
|
||||
The absolute path to the base directory of the jsdoc application.
|
||||
@type string
|
||||
*/
|
||||
@ -151,7 +154,9 @@ function installPlugins(plugins, p) {
|
||||
//...register event handlers
|
||||
if (plugin.handlers) {
|
||||
for (var eventName in plugin.handlers) {
|
||||
parser.on(eventName, plugin.handlers[eventName]);
|
||||
if ( hasOwnProp.call(plugin.handlers, eventName) ) {
|
||||
parser.on(eventName, plugin.handlers[eventName]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,8 +173,7 @@ function installPlugins(plugins, p) {
|
||||
}
|
||||
|
||||
function indexAll(docs) {
|
||||
var lookupTable = {},
|
||||
hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var lookupTable = {};
|
||||
|
||||
docs.forEach(function(doc) {
|
||||
if ( !hasOwnProp.call(lookupTable, doc.longname) ) {
|
||||
@ -260,8 +264,8 @@ function main() {
|
||||
}
|
||||
|
||||
if (/(\bREADME|\.md)$/i.test(env.opts._[i])) {
|
||||
var readme = require('jsdoc/readme');
|
||||
env.opts.readme = new readme(env.opts._[i]).html;
|
||||
var Readme = require('jsdoc/readme');
|
||||
env.opts.readme = new Readme(env.opts._[i]).html;
|
||||
env.opts._.splice(i--, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
/*global env: true */
|
||||
/**
|
||||
@overview Translate doclet descriptions from MarkDown into HTML.
|
||||
@module plugins/markdown
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
/*global Packages: true */
|
||||
exports.readFileSync = function(filename, encoding) {
|
||||
encoding = encoding || 'utf-8';
|
||||
|
||||
|
||||
@ -23,14 +23,16 @@ var doop = require("jsdoc/util/doop").doop;
|
||||
function mapDependencies(index) {
|
||||
var doclets, doc, len, dependencies = {};
|
||||
for (var name in index) {
|
||||
doclets = index[name];
|
||||
for (var i=0, ii=doclets.length; i<ii; ++i) {
|
||||
doc = doclets[i];
|
||||
if (doc.kind === "class") {
|
||||
dependencies[name] = {};
|
||||
len = doc.augments && doc.augments.length || 0;
|
||||
for (var j=0; j<len; ++j) {
|
||||
dependencies[name][doc.augments[j]] = true;
|
||||
if ( hasOwnProp.call(index, name) ) {
|
||||
doclets = index[name];
|
||||
for (var i=0, ii=doclets.length; i<ii; ++i) {
|
||||
doc = doclets[i];
|
||||
if (doc.kind === "class") {
|
||||
dependencies[name] = {};
|
||||
len = doc.augments && doc.augments.length || 0;
|
||||
for (var j=0; j<len; ++j) {
|
||||
dependencies[name][doc.augments[j]] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -40,7 +42,7 @@ var doop = require("jsdoc/util/doop").doop;
|
||||
|
||||
function getAdditions(doclets, docs) {
|
||||
var additions = [];
|
||||
var doc, parents, members, member;
|
||||
var doc, parents, members, member, parts;
|
||||
for (var i=0, ii=doclets.length; i<ii; ++i) {
|
||||
doc = doclets[i];
|
||||
parents = doc.augments;
|
||||
@ -83,7 +85,9 @@ var doop = require("jsdoc/util/doop").doop;
|
||||
Sorter.prototype = {
|
||||
sort: function() {
|
||||
for (var key in this.dependencies) {
|
||||
this.visit(key);
|
||||
if ( hasOwnProp.call(this.dependencies, key) ) {
|
||||
this.visit(key);
|
||||
}
|
||||
}
|
||||
return this.sorted;
|
||||
},
|
||||
@ -94,7 +98,9 @@ var doop = require("jsdoc/util/doop").doop;
|
||||
throw new Error("Missing dependency: " + key);
|
||||
}
|
||||
for (var path in this.dependencies[key]) {
|
||||
this.visit(path);
|
||||
if ( hasOwnProp.call(this.dependencies[key], path) ) {
|
||||
this.visit(path);
|
||||
}
|
||||
}
|
||||
this.sorted.push(key);
|
||||
}
|
||||
@ -107,4 +113,4 @@ var doop = require("jsdoc/util/doop").doop;
|
||||
}
|
||||
|
||||
|
||||
})();
|
||||
}());
|
||||
|
||||
@ -32,8 +32,8 @@ exports.resolveBorrows = function(docs) {
|
||||
asName = asName.replace(/^prototype\./, '#');
|
||||
var parts = asName.split('#');
|
||||
|
||||
if (parts.length === 2) clone.scope = 'instance';
|
||||
else clone.scope = 'static';
|
||||
if (parts.length === 2) { clone.scope = 'instance'; }
|
||||
else { clone.scope = 'static'; }
|
||||
|
||||
asName = parts.pop();
|
||||
clone.name = asName;
|
||||
|
||||
@ -27,7 +27,7 @@ module.exports = Config;
|
||||
@class
|
||||
@classdesc Represents a JSDoc application configuration.
|
||||
@param {string} [json] - The contents of config.json.
|
||||
*/
|
||||
*/
|
||||
function Config(json) {
|
||||
var json = JSON.parse( (json || "{}") );
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@ exports.Doclet = function(docletSrc, meta) {
|
||||
exports.Doclet.prototype.postProcess = function() {
|
||||
if (!this.preserveName) { jsdoc.name.resolve(this); }
|
||||
if (this.name && !this.longname) {
|
||||
this.setLongname(this.name);
|
||||
this.setLongname(this.name);
|
||||
}
|
||||
if (this.memberof === '') {
|
||||
delete(this.memberof);
|
||||
@ -126,7 +126,7 @@ exports.Doclet.prototype.setLongname = function(name) {
|
||||
*/
|
||||
exports.Doclet.prototype.borrow = function(source, target) {
|
||||
var about = {from: source};
|
||||
if (target) about.as = target;
|
||||
if (target) { about.as = target; }
|
||||
|
||||
if (!this.borrowed) {
|
||||
/**
|
||||
@ -203,7 +203,7 @@ exports.Doclet.prototype.setMeta = function(meta) {
|
||||
@namespace
|
||||
*/
|
||||
this.meta.code = (this.meta.code || {});
|
||||
if (meta.id) this.meta.code.id = meta.id;
|
||||
if (meta.id) { this.meta.code.id = meta.id; }
|
||||
if (meta.code) {
|
||||
if (meta.code.name) {
|
||||
/** The name of the symbol in the source code. */
|
||||
@ -300,7 +300,9 @@ function fixDescription(docletSrc) {
|
||||
}
|
||||
|
||||
function split(docletSrc) {
|
||||
var tagSrcs = [];
|
||||
var tagSrcs = [],
|
||||
tagText,
|
||||
tagTitle;
|
||||
|
||||
// split out the basic tags, keep surrounding whitespace
|
||||
// like: @tagTitle tagBody
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
/*global Packages: true */
|
||||
/**
|
||||
A collection of functions relating to JSDoc symbol name manipulation.
|
||||
@module jsdoc/name
|
||||
@ -79,7 +80,9 @@ exports.resolve = function(doclet) {
|
||||
doclet.scope = puncToScope[RegExp.$1];
|
||||
doclet.name = doclet.name.substr(1);
|
||||
}
|
||||
else doclet.scope = 'static'; // default scope when none is provided
|
||||
else {
|
||||
doclet.scope = 'static'; // default scope when none is provided
|
||||
}
|
||||
|
||||
doclet.setLongname(doclet.memberof + scopeToPunc[doclet.scope] + doclet.name);
|
||||
}
|
||||
@ -139,7 +142,7 @@ exports.applyNamespace = function(longname, ns) {
|
||||
*/
|
||||
exports.shorten = function(longname, forcedMemberof) {
|
||||
// quoted strings in a longname are atomic, convert to tokens
|
||||
var atoms = [], token;
|
||||
var atoms = [], token;
|
||||
|
||||
// handle quoted names like foo["bar"]
|
||||
longname = longname.replace(/(\[?".+?"\]?)/g, function($) {
|
||||
@ -166,8 +169,8 @@ exports.shorten = function(longname, forcedMemberof) {
|
||||
name = longname.substr(forcedMemberof.length);
|
||||
var parts = forcedMemberof.match(/^(.*?)([#.~]?)$/);
|
||||
|
||||
if (parts[1]) memberof = parts[1] || forcedMemberof;
|
||||
if (parts[2]) scope = parts[2];
|
||||
if (parts[1]) { memberof = parts[1] || forcedMemberof; }
|
||||
if (parts[2]) { scope = parts[2]; }
|
||||
}
|
||||
else {
|
||||
var parts = longname?
|
||||
|
||||
@ -47,14 +47,14 @@ exports.Package = function(json) {
|
||||
*/
|
||||
this.description = json.description;
|
||||
|
||||
/**
|
||||
/**
|
||||
The hash summary of the source file.
|
||||
@type {string}
|
||||
@since 3.2.0
|
||||
*/
|
||||
this.version = json.version;
|
||||
|
||||
/**
|
||||
/**
|
||||
* The licenses of this package.
|
||||
* @type {Array<Object>}
|
||||
* @example
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
/*global env: true */
|
||||
/**
|
||||
@overview
|
||||
@author Michael Mathews <micmath@gmail.com>
|
||||
|
||||
@ -14,10 +14,10 @@
|
||||
*/
|
||||
exports.Filter = function(opts) {
|
||||
this.exclude = opts.exclude || null;
|
||||
this.includePattern = opts.includePattern?
|
||||
this.includePattern = opts.includePattern?
|
||||
typeof opts.includePattern === 'string'? new RegExp(opts.includePattern) : opts.includePattern
|
||||
: null;
|
||||
this.excludePattern = opts.excludePattern?
|
||||
this.excludePattern = opts.excludePattern?
|
||||
typeof opts.excludePattern === 'string'? new RegExp(opts.excludePattern) : opts.excludePattern
|
||||
: null;
|
||||
}
|
||||
|
||||
@ -146,6 +146,7 @@ exports.attachTo = function(parser) {
|
||||
});
|
||||
|
||||
function addDoclet(newDoclet) {
|
||||
var e;
|
||||
if (newDoclet) {
|
||||
e = { doclet: newDoclet };
|
||||
this.fire('newDoclet', e);
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
/*global Packages: true */
|
||||
/**
|
||||
* @module jsdoc/src/parser
|
||||
* @requires common/util
|
||||
@ -47,7 +48,9 @@ require('common/util').mixin(exports.Parser.prototype, require('common/events'))
|
||||
exports.Parser.prototype.parse = function(sourceFiles, encoding) {
|
||||
const SCHEMA = 'javascript:';
|
||||
var sourceCode = '',
|
||||
filename = '';
|
||||
filename = '',
|
||||
i,
|
||||
leni;
|
||||
|
||||
if (typeof sourceFiles === 'string') { sourceFiles = [sourceFiles]; }
|
||||
|
||||
@ -199,7 +202,9 @@ exports.Parser.prototype.astnodeToMemberof = function(node) {
|
||||
|
||||
id = 'astnode'+node.parent.hashCode();
|
||||
doclet = this.refs[id];
|
||||
if (!doclet) return ''; // global?
|
||||
if (!doclet) {
|
||||
return ''; // global?
|
||||
}
|
||||
return doclet.longname||doclet.name;
|
||||
}
|
||||
}
|
||||
@ -236,16 +241,22 @@ exports.Parser.prototype.resolveThis = function(node) {
|
||||
if (node.enclosingFunction){
|
||||
return this.resolveThis(node.enclosingFunction/* memberof.doclet.meta.code.val */);
|
||||
}
|
||||
else return ''; // TODO handle global this?
|
||||
else {
|
||||
return ''; // TODO handle global this?
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (node.parent) {
|
||||
var parent = node.parent;
|
||||
if (parent.type === Token.COLON) parent = parent.parent; // go up one more
|
||||
if (parent.type === Token.COLON) {
|
||||
parent = parent.parent; // go up one more
|
||||
}
|
||||
|
||||
memberof.id = 'astnode'+parent.hashCode();
|
||||
memberof.doclet = this.refs[memberof.id];
|
||||
if (!memberof.doclet) return ''; // global?
|
||||
if (!memberof.doclet) {
|
||||
return ''; // global?
|
||||
}
|
||||
|
||||
return memberof.doclet.longname||memberof.doclet.name;
|
||||
}
|
||||
@ -262,7 +273,9 @@ exports.Parser.prototype.resolvePropertyParent = function(node) {
|
||||
|
||||
if (node.parent) {
|
||||
var parent = node.parent;
|
||||
if (parent.type === Token.COLON) parent = parent.parent; // go up one more
|
||||
if (parent.type === Token.COLON) {
|
||||
parent = parent.parent; // go up one more
|
||||
}
|
||||
|
||||
memberof.id = 'astnode'+parent.hashCode();
|
||||
memberof.doclet = this.refs[memberof.id];
|
||||
@ -366,7 +379,9 @@ function visitNode(node) {
|
||||
|
||||
var basename = getBasename(e.code.name);
|
||||
|
||||
if (basename !== 'this') e.code.funcscope = currentParser.resolveVar(node, basename);
|
||||
if (basename !== 'this') {
|
||||
e.code.funcscope = currentParser.resolveVar(node, basename);
|
||||
}
|
||||
}
|
||||
else if (node.type === Token.COLON) { // assignment within an object literal
|
||||
e = {
|
||||
@ -484,7 +499,7 @@ function parserFactory() {
|
||||
* @memberof module:src/parser.Parser
|
||||
*/
|
||||
function aboutNode(node) {
|
||||
about = {};
|
||||
var about = {};
|
||||
|
||||
if (node.type == Token.FUNCTION || node.type == tkn.NAMEDFUNCTIONSTATEMENT) {
|
||||
about.name = node.type == tkn.NAMEDFUNCTIONSTATEMENT? '' : '' + node.name;
|
||||
@ -554,7 +569,7 @@ function aboutNode(node) {
|
||||
function nodeToString(node) {
|
||||
var str;
|
||||
|
||||
if (!node) return;
|
||||
if (!node) { return; }
|
||||
|
||||
if (node.type === Token.GETPROP) {
|
||||
str = [nodeToString(node.target), node.property.string].join('.');
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
/*global env: true */
|
||||
/**
|
||||
@overview
|
||||
@author Michael Mathews <micmath@gmail.com>
|
||||
|
||||
@ -9,7 +9,8 @@ var _synonyms = {},
|
||||
_namespaces = [],
|
||||
hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
|
||||
function _TagDefinition(title, etc) {
|
||||
/** @private */
|
||||
function TagDefinition(title, etc) {
|
||||
etc = etc || {};
|
||||
|
||||
this.title = dictionary.normalise(title);
|
||||
@ -21,7 +22,8 @@ function _TagDefinition(title, etc) {
|
||||
}
|
||||
}
|
||||
|
||||
_TagDefinition.prototype.synonym = function(synonymName) {
|
||||
/** @private */
|
||||
TagDefinition.prototype.synonym = function(synonymName) {
|
||||
_synonyms[synonymName.toLowerCase()] = this.title;
|
||||
return this; // chainable
|
||||
}
|
||||
@ -30,7 +32,7 @@ _TagDefinition.prototype.synonym = function(synonymName) {
|
||||
var dictionary = {
|
||||
/** @function */
|
||||
defineTag: function(title, opts) {
|
||||
_definitions[title] = new _TagDefinition(title, opts);
|
||||
_definitions[title] = new TagDefinition(title, opts);
|
||||
|
||||
if (opts.isNamespace) {
|
||||
_namespaces.push(title);
|
||||
@ -52,12 +54,16 @@ var dictionary = {
|
||||
|
||||
/** @function */
|
||||
isNamespace: function(kind) {
|
||||
return ( ~ _namespaces.indexOf(kind) );
|
||||
if ( _namespaces.indexOf(kind) !== -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
/** @function */
|
||||
normalise: function(title) {
|
||||
canonicalName = title.toLowerCase();
|
||||
var canonicalName = title.toLowerCase();
|
||||
|
||||
if ( hasOwnProp.call(_synonyms, canonicalName) ) {
|
||||
return _synonyms[canonicalName];
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
/*global app: true, env: true */
|
||||
/**
|
||||
Define tags that are known in JSDoc.
|
||||
@module jsdoc/tag/dictionary/definitions
|
||||
@ -28,7 +29,7 @@ exports.defineTags = function(dictionary) {
|
||||
doclet.access = tag.value.toLowerCase();
|
||||
}
|
||||
else {
|
||||
delete doclet.access;
|
||||
delete doclet.access;
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -291,7 +292,7 @@ exports.defineTags = function(dictionary) {
|
||||
|
||||
dictionary.defineTag('instance', {
|
||||
onTagged: function(doclet, tag) {
|
||||
setDocletScopeToTitle(doclet, tag);
|
||||
setDocletScopeToTitle(doclet, tag);
|
||||
}
|
||||
});
|
||||
|
||||
@ -465,7 +466,7 @@ exports.defineTags = function(dictionary) {
|
||||
|
||||
dictionary.defineTag('static', {
|
||||
onTagged: function(doclet, tag) {
|
||||
setDocletScopeToTitle(doclet, tag);
|
||||
setDocletScopeToTitle(doclet, tag);
|
||||
}
|
||||
});
|
||||
|
||||
@ -513,7 +514,9 @@ exports.defineTags = function(dictionary) {
|
||||
onTagged: function(doclet, tag) {
|
||||
if (tag.value && tag.value.type) {
|
||||
doclet.type = tag.value.type;
|
||||
if (doclet.kind === 'function') doclet.addTag('returns', tag.text); // for backwards compatibility we allow @type for functions to imply return type
|
||||
if (doclet.kind === 'function') {
|
||||
doclet.addTag('returns', tag.text); // for backwards compatibility we allow @type for functions to imply return type
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -583,7 +586,7 @@ function setDocletDescriptionToValue(doclet, tag) {
|
||||
}
|
||||
|
||||
function setNameToFile(doclet, tag) {
|
||||
if (doclet.meta.filename) {
|
||||
if (doclet.meta.filename) {
|
||||
var name = 'file:';
|
||||
if (doclet.meta.path) { name += doclet.meta.path + java.lang.System.getProperty("file.separator"); }
|
||||
doclet.addTag( 'name', name + doclet.meta.filename );
|
||||
@ -601,7 +604,9 @@ function applyNamespace(docletOrNs, tag) {
|
||||
tag.value = app.jsdoc.name.applyNamespace(tag.value, docletOrNs);
|
||||
}
|
||||
else { // doclet
|
||||
if (!docletOrNs.name) return; // error?
|
||||
if (!docletOrNs.name) {
|
||||
return; // error?
|
||||
}
|
||||
|
||||
//doclet.displayname = doclet.name;
|
||||
docletOrNs.longname = app.jsdoc.name.applyNamespace(docletOrNs.name, tag.title);
|
||||
|
||||
@ -82,7 +82,7 @@ function parseVariable(type) {
|
||||
function parseTypes(type) {
|
||||
var types = [];
|
||||
|
||||
if ( ~type.indexOf('|') ) {
|
||||
if ( type.indexOf('|') !== -1 ) {
|
||||
// remove optional parens, like: { ( string | number ) }
|
||||
// see: http://code.google.com/closure/compiler/docs/js-for-compiler.html#types
|
||||
if ( /^\s*\(\s*(.+)\s*\)\s*$/.test(type) ) {
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
/*global env: true */
|
||||
/**
|
||||
@module jsdoc/tag/validator
|
||||
@requires jsdoc/tag/dictionary
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
var tutorial = require('jsdoc/tutorial'),
|
||||
fs = require('fs'),
|
||||
hasOwnProp = Object.prototype.hasOwnProperty,
|
||||
conf = {},
|
||||
tutorials = {},
|
||||
finder = /^(.*)\.(x(?:ht)?ml|html?|md|markdown|js(?:on)?)$/i;
|
||||
@ -44,6 +45,7 @@ exports.load = function(path) {
|
||||
var match,
|
||||
type,
|
||||
name,
|
||||
content,
|
||||
current,
|
||||
files = fs.ls(path);
|
||||
|
||||
@ -97,32 +99,34 @@ exports.resolve = function() {
|
||||
var item,
|
||||
current;
|
||||
for (var name in conf) {
|
||||
// should we be restrictive here?
|
||||
// what is someone just wants to keep sample sources in same directory with tutorials?
|
||||
// I've decided to leave such cases alone
|
||||
if (!(name in tutorials)) {
|
||||
continue;
|
||||
}
|
||||
if ( hasOwnProp.call(conf, name) ) {
|
||||
// should we be restrictive here?
|
||||
// what is someone just wants to keep sample sources in same directory with tutorials?
|
||||
// I've decided to leave such cases alone
|
||||
if (!(name in tutorials)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
item = conf[name];
|
||||
current = tutorials[name]
|
||||
item = conf[name];
|
||||
current = tutorials[name]
|
||||
|
||||
// set title
|
||||
if (item.title) {
|
||||
current.title = item.title;
|
||||
}
|
||||
// set title
|
||||
if (item.title) {
|
||||
current.title = item.title;
|
||||
}
|
||||
|
||||
// add children
|
||||
if (item.children) {
|
||||
item.children.forEach(function(child) {
|
||||
// I really didn't want to throw you an exception in most cases
|
||||
// but now, user, you pissed me off ;)
|
||||
if (!(child in tutorials)) {
|
||||
throw new Error("Missing child tutorial: " + child);
|
||||
}
|
||||
// add children
|
||||
if (item.children) {
|
||||
item.children.forEach(function(child) {
|
||||
// I really didn't want to throw you an exception in most cases
|
||||
// but now, user, you pissed me off ;)
|
||||
if (!(child in tutorials)) {
|
||||
throw new Error("Missing child tutorial: " + child);
|
||||
}
|
||||
|
||||
tutorials[child].setParent(current);
|
||||
});
|
||||
tutorials[child].setParent(current);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -10,8 +10,8 @@ var doop = exports.doop = function(o) {
|
||||
clone = o instanceof Array ? [] : {};
|
||||
|
||||
for (prop in o){
|
||||
if ( hasOwnProp.call(o, prop) ) {
|
||||
clone[prop] = (o[prop] instanceof Object)? doop(o[prop]) : o[prop];
|
||||
if ( hasOwnProp.call(o, prop) ) {
|
||||
clone[prop] = (o[prop] instanceof Object)? doop(o[prop]) : o[prop];
|
||||
}
|
||||
}
|
||||
return clone;
|
||||
|
||||
@ -37,7 +37,7 @@ function pad(depth) {
|
||||
*/
|
||||
function indent(openingBrace) {
|
||||
indentBy++;
|
||||
if (openingBrace) output += openingBrace + '\n';
|
||||
if (openingBrace) { output += openingBrace + '\n'; }
|
||||
}
|
||||
|
||||
/**
|
||||
@ -51,7 +51,7 @@ function outdent(closingBrace) {
|
||||
indentBy--;
|
||||
output = output.replace(/,\n$/, '\n'); // trim trailing comma
|
||||
if (closingBrace === false) { output = output.replace(/\n$/, ''); }
|
||||
else if (closingBrace) output += pad(indentBy) + closingBrace + ',\n';
|
||||
else if (closingBrace) { output += pad(indentBy) + closingBrace + ',\n'; }
|
||||
}
|
||||
|
||||
var seen = [];
|
||||
|
||||
@ -131,7 +131,7 @@ exports.setTutorials = function(root) {
|
||||
tutorials = root;
|
||||
};
|
||||
|
||||
exports.toTutorial = toTutorial = function(tutorial, content) {
|
||||
var toTutorial = exports.toTutorial = function(tutorial, content) {
|
||||
if (!tutorial) {
|
||||
throw new Error('Missing required parameter: tutorial');
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
/*global env: true, publish: true */
|
||||
(function() {
|
||||
|
||||
var template = require('jsdoc/template'),
|
||||
@ -14,7 +15,7 @@
|
||||
*/
|
||||
publish = function(data, opts, tutorials) {
|
||||
var defaultTemplatePath = 'templates/default';
|
||||
var templatePath = (opts.template) ? opts.template : defaultTemplate;
|
||||
var templatePath = (opts.template) ? opts.template : defaultTemplatePath;
|
||||
var out = '',
|
||||
view = new template.Template(env.dirname + '/' + templatePath + '/tmpl');
|
||||
|
||||
@ -53,7 +54,7 @@
|
||||
while (doc = doc.memberof) {
|
||||
doc = find({longname: doc});
|
||||
if (doc) { doc = doc[0]; }
|
||||
if (!doc) break;
|
||||
if (!doc) { break; }
|
||||
ancestors.unshift( linkto(doc.longname, (scopeToPunc[doc.scope] || '') + doc.name) );
|
||||
}
|
||||
if (ancestors.length) {
|
||||
@ -92,8 +93,8 @@
|
||||
types = types.map(function(t) {
|
||||
return linkto(t, htmlsafe(t));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
f.signature = (f.signature || '') + '<span class="type-signature">'+(types.length? ' :'+types.join('|') : '')+'</span>';
|
||||
}
|
||||
|
||||
@ -109,11 +110,15 @@
|
||||
}
|
||||
|
||||
if (f.scope && f.scope !== 'instance' && f.scope !== 'global') {
|
||||
if (f.kind == 'function' || f.kind == 'member' || f.kind == 'constant') attribs.push(f.scope);
|
||||
if (f.kind == 'function' || f.kind == 'member' || f.kind == 'constant') {
|
||||
attribs.push(f.scope);
|
||||
}
|
||||
}
|
||||
|
||||
if (f.readonly === true) {
|
||||
if (f.kind == 'member') attribs.push('readonly');
|
||||
if (f.kind == 'member') {
|
||||
attribs.push('readonly');
|
||||
}
|
||||
}
|
||||
|
||||
if (f.kind === 'constant') {
|
||||
@ -246,7 +251,9 @@
|
||||
if (moduleNames.length) {
|
||||
nav += '<h3>Modules</h3><ul>';
|
||||
moduleNames.forEach(function(m) {
|
||||
if ( !hasOwnProp.call(seen, m.longname) ) nav += '<li>'+linkto(m.longname, m.name)+'</li>';
|
||||
if ( !hasOwnProp.call(seen, m.longname) ) {
|
||||
nav += '<li>'+linkto(m.longname, m.name)+'</li>';
|
||||
}
|
||||
seen[m.longname] = true;
|
||||
});
|
||||
|
||||
@ -260,7 +267,9 @@
|
||||
if (externalNames.length) {
|
||||
nav += '<h3>Externals</h3><ul>';
|
||||
externalNames.forEach(function(e) {
|
||||
if ( !hasOwnProp.call(seen, e.longname) ) nav += '<li>'+linkto( e.longname, e.name.replace(/(^"|"$)/g, '') )+'</li>';
|
||||
if ( !hasOwnProp.call(seen, e.longname) ) {
|
||||
nav += '<li>'+linkto( e.longname, e.name.replace(/(^"|"$)/g, '') )+'</li>';
|
||||
}
|
||||
seen[e.longname] = true;
|
||||
});
|
||||
|
||||
@ -284,7 +293,9 @@
|
||||
nav += '<h3>Classes</h3><ul>';
|
||||
moduleClasses = -1;
|
||||
}
|
||||
if ( !hasOwnProp.call(seen, c.longname) ) nav += '<li>'+linkto(c.longname, c.name)+'</li>';
|
||||
if ( !hasOwnProp.call(seen, c.longname) ) {
|
||||
nav += '<li>'+linkto(c.longname, c.name)+'</li>';
|
||||
}
|
||||
seen[c.longname] = true;
|
||||
});
|
||||
|
||||
@ -298,7 +309,9 @@
|
||||
if (namespaceNames.length) {
|
||||
nav += '<h3>Namespaces</h3><ul>';
|
||||
namespaceNames.forEach(function(n) {
|
||||
if ( !hasOwnProp.call(seen, n.longname) ) nav += '<li>'+linkto(n.longname, n.name)+'</li>';
|
||||
if ( !hasOwnProp.call(seen, n.longname) ) {
|
||||
nav += '<li>'+linkto(n.longname, n.name)+'</li>';
|
||||
}
|
||||
seen[n.longname] = true;
|
||||
});
|
||||
|
||||
@ -309,10 +322,12 @@
|
||||
// if (constantNames.length) {
|
||||
// nav += '<h3>Constants</h3><ul>';
|
||||
// constantNames.forEach(function(c) {
|
||||
// if ( !hasOwnProp.call(seen, c.longname) ) nav += '<li>'+linkto(c.longname, c.name)+'</li>';
|
||||
// if ( !hasOwnProp.call(seen, c.longname) ) {
|
||||
// nav += '<li>'+linkto(c.longname, c.name)+'</li>';
|
||||
// }
|
||||
// seen[c.longname] = true;
|
||||
// });
|
||||
//
|
||||
//
|
||||
// nav += '</ul>';
|
||||
// }
|
||||
|
||||
@ -323,7 +338,9 @@
|
||||
if (mixinNames.length) {
|
||||
nav += '<h3>Mixins</h3><ul>';
|
||||
mixinNames.forEach(function(m) {
|
||||
if ( !hasOwnProp.call(seen, m.longname) ) nav += '<li>'+linkto(m.longname, m.name)+'</li>';
|
||||
if ( !hasOwnProp.call(seen, m.longname) ) {
|
||||
nav += '<li>'+linkto(m.longname, m.name)+'</li>';
|
||||
}
|
||||
seen[m.longname] = true;
|
||||
});
|
||||
|
||||
@ -347,7 +364,9 @@
|
||||
nav += '<h3>Global</h3><ul>';
|
||||
|
||||
globalNames.forEach(function(g) {
|
||||
if ( g.kind !== 'typedef' && !hasOwnProp.call(seen, g.longname) ) nav += '<li>'+linkto(g.longname, g.name)+'</li>';
|
||||
if ( g.kind !== 'typedef' && !hasOwnProp.call(seen, g.longname) ) {
|
||||
nav += '<li>'+linkto(g.longname, g.name)+'</li>';
|
||||
}
|
||||
seen[g.longname] = true;
|
||||
});
|
||||
|
||||
@ -363,26 +382,28 @@
|
||||
view.nav = nav;
|
||||
|
||||
for (var longname in helper.longnameToUrl) {
|
||||
var classes = find({kind: 'class', longname: longname});
|
||||
if (classes.length) generate('Class: '+classes[0].name, classes, helper.longnameToUrl[longname]);
|
||||
if ( hasOwnProp.call(helper.longnameToUrl, longname) ) {
|
||||
var classes = find({kind: 'class', longname: longname});
|
||||
if (classes.length) { generate('Class: '+classes[0].name, classes, helper.longnameToUrl[longname]); }
|
||||
|
||||
var modules = find({kind: 'module', longname: longname});
|
||||
if (modules.length) generate('Module: '+modules[0].name, modules, helper.longnameToUrl[longname]);
|
||||
var modules = find({kind: 'module', longname: longname});
|
||||
if (modules.length) { generate('Module: '+modules[0].name, modules, helper.longnameToUrl[longname]); }
|
||||
|
||||
var namespaces = find({kind: 'namespace', longname: longname});
|
||||
if (namespaces.length) generate('Namespace: '+namespaces[0].name, namespaces, helper.longnameToUrl[longname]);
|
||||
var namespaces = find({kind: 'namespace', longname: longname});
|
||||
if (namespaces.length) { generate('Namespace: '+namespaces[0].name, namespaces, helper.longnameToUrl[longname]); }
|
||||
|
||||
// var constants = find({kind: 'constant', longname: longname});
|
||||
// if (constants.length) generate('Constant: '+constants[0].name, constants, helper.longnameToUrl[longname]);
|
||||
// var constants = find({kind: 'constant', longname: longname});
|
||||
// if (constants.length) { generate('Constant: '+constants[0].name, constants, helper.longnameToUrl[longname]); }
|
||||
|
||||
var mixins = find({kind: 'mixin', longname: longname});
|
||||
if (mixins.length) generate('Mixin: '+mixins[0].name, mixins, helper.longnameToUrl[longname]);
|
||||
var mixins = find({kind: 'mixin', longname: longname});
|
||||
if (mixins.length) { generate('Mixin: '+mixins[0].name, mixins, helper.longnameToUrl[longname]); }
|
||||
|
||||
var externals = find({kind: 'external', longname: longname});
|
||||
if (externals.length) generate('External: '+externals[0].name, externals, helper.longnameToUrl[longname]);
|
||||
var externals = find({kind: 'external', longname: longname});
|
||||
if (externals.length) { generate('External: '+externals[0].name, externals, helper.longnameToUrl[longname]); }
|
||||
}
|
||||
}
|
||||
|
||||
if (globals.length) generate('Global', [{kind: 'globalobj'}], 'global.html');
|
||||
if (globals.length) { generate('Global', [{kind: 'globalobj'}], 'global.html'); }
|
||||
|
||||
// index page displays information from package.json and lists files
|
||||
var files = find({kind: 'file'}),
|
||||
@ -445,4 +466,4 @@
|
||||
return '<a href="'+url+'">'+hash+'</a>';
|
||||
}
|
||||
|
||||
})();
|
||||
}());
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
/*global publish: true */
|
||||
/**
|
||||
@overview Builds a tree-like JSON string from the doclet data.
|
||||
@version 0.0.1
|
||||
@ -39,7 +40,7 @@
|
||||
|
||||
function graft(parentNode, childNodes, parentLongname, parentName) {
|
||||
childNodes
|
||||
.filter(function (element) {
|
||||
.filter(function (element) {
|
||||
return (element.memberof === parentLongname);
|
||||
})
|
||||
.forEach(function (element, i) {
|
||||
@ -209,5 +210,5 @@
|
||||
});
|
||||
}
|
||||
|
||||
})();
|
||||
}());
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user