Work on templates. Replaced mustache with Underscore Template code.

This commit is contained in:
Michael Mathews 2011-02-24 17:09:10 +00:00
parent 10a71c6b4b
commit 6a52c03201
29 changed files with 943 additions and 1293 deletions

View File

@ -7,7 +7,7 @@ compliance with the License. You have permission to use it for commercial,
non-commercial, or any other purpose you like, according to the
License below.
Copyright (c) 2010, 2011 Michael Mathews <micmath@gmail.com>
Copyright (c) 2011 Michael Mathews <micmath@gmail.com>
All rights reserved.
You may obtain a copy of the License at
@ -158,33 +158,19 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
You may obtain the source code for sqlitejdbc at
https://github.com/crawshaw/sqlitejdbc
MustacheJS (templates/lib/janl/mustache.js)
Underscore Template (templates/lib/underscore/template.js)
----
Copyright (c) 2009 Chris Wanstrath (Ruby)
Copyright (c) 2010 Jan Lehnardt (JavaScript)
Underscore.js 1.1.4
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.
You may obtain the source code for MustacheJS at
https://github.com/janl/mustache.js
Underscore is freely distributable under the MIT license.
Portions of Underscore are inspired or borrowed from Prototype,
Oliver Steele's Functional, and John Resig's Micro-Templating.
For all details and documentation:
http://documentcloud.github.com/underscore/#template
TaffyDB (modules/typicaljoe/taffy.js)
----

View File

@ -1,348 +0,0 @@
/*
* CommonJS-compatible mustache.js module
*
* See http://github.com/janl/mustache.js for more info.
*/
/*
mustache.js Logic-less templates in JavaScript
See http://mustache.github.com/ for more info.
*/
var Mustache = function() {
var Renderer = function() {};
Renderer.prototype = {
otag: "{{",
ctag: "}}",
pragmas: {},
buffer: [],
pragmas_implemented: {
"IMPLICIT-ITERATOR": true,
"ARRAY-ORDINALS": true // define #first? and #last? when looping arrays
},
context: {},
render: function(template, context, partials, in_recursion) {
// reset buffer & set context
if(!in_recursion) {
this.context = context;
this.buffer = []; // TODO: make this non-lazy
}
// fail fast
if(!this.includes("", template)) {
if(in_recursion) {
return template;
} else {
this.send(template);
return;
}
}
template = this.render_pragmas(template);
var html = this.render_section(template, context, partials);
if(in_recursion) {
return this.render_tags(html, context, partials, in_recursion);
}
this.render_tags(html, context, partials, in_recursion);
},
/*
Sends parsed lines
*/
send: function(line) {
if(line != "") {
this.buffer.push(line);
}
},
/*
Looks for %PRAGMAS
*/
render_pragmas: function(template) {
// no pragmas
if(!this.includes("%", template)) {
return template;
}
var that = this;
var regex = new RegExp(this.otag + "%([\\w-]+) ?([\\w]+=[\\w]+)?" +
this.ctag);
return template.replace(regex, function(match, pragma, options) {
if(!that.pragmas_implemented[pragma]) {
throw({message:
"This implementation of mustache doesn't understand the '" +
pragma + "' pragma"});
}
that.pragmas[pragma] = {};
if(options) {
var opts = options.split("=");
that.pragmas[pragma][opts[0]] = opts[1];
}
return "";
// ignore unknown pragmas silently
});
},
/*
Tries to find a partial in the curent scope and render it
*/
render_partial: function(name, context, partials) {
name = this.trim(name);
if(!partials || partials[name] === undefined) {
throw({message: "unknown_partial '" + name + "'"});
}
if(typeof(context[name]) != "object") {
return this.render(partials[name], context, partials, true);
}
return this.render(partials[name], context[name], partials, true);
},
/*
Renders inverted (^) and normal (#) sections
*/
render_section: function(template, context, partials) {
if(!this.includes("#", template) && !this.includes("^", template)) {
return template;
}
var that = this;
// CSW - Added "+?" so it finds the tighest bound, not the widest
var regex = new RegExp(this.otag + "(\\^|\\#)\\s*(.+)\\s*" + this.ctag +
"\n*([\\s\\S]+?)" + this.otag + "\\/\\s*\\2\\s*" + this.ctag +
"\\s*", "mg");
// for each {{#foo}}{{/foo}} section do...
return template.replace(regex, function(match, type, name, content) {
var value = that.find(name, context);
if(type == "^") { // inverted section
if(!value || that.is_array(value) && value.length === 0) {
// false or empty list, render it
return that.render(content, context, partials, true);
} else {
return "";
}
} else if(type == "#") { // normal section
if(that.is_array(value)) { // Enumerable, Let's loop!
var len = value.length;
return value.map(function(row, i) {
return that.render(content, that.create_context(row, {first: i === 0, last: i === len-1}),
partials, true);
}).join("");
} else if(that.is_object(value)) { // Object, Use it as subcontext!
return that.render(content, that.create_context(value),
partials, true);
} else if(typeof value === "function") {
// higher order section
return value.call(context, content, function(text) {
return that.render(text, context, partials, true);
});
} else if(value) { // boolean section
return that.render(content, context, partials, true);
} else {
return "";
}
}
});
},
/*
Replace {{foo}} and friends with values from our view
*/
render_tags: function(template, context, partials, in_recursion) {
// tit for tat
var that = this;
var new_regex = function() {
return new RegExp(that.otag + "(=|!|>|\\{|%)?([^\\/#\\^]+?)\\1?" +
that.ctag + "+", "g");
};
var regex = new_regex();
var tag_replace_callback = function(match, operator, name) {
switch(operator) {
case "!": // ignore comments
return "";
case "=": // set new delimiters, rebuild the replace regexp
that.set_delimiters(name);
regex = new_regex();
return "";
case ">": // render partial
return that.render_partial(name, context, partials);
case "{": // the triple mustache is unescaped
return that.find(name, context);
default: // escape the value
return that.escape(that.find(name, context));
}
};
var lines = template.split("\n");
for(var i = 0; i < lines.length; i++) {
lines[i] = lines[i].replace(regex, tag_replace_callback, this);
if(!in_recursion) {
this.send(lines[i]);
}
}
if(in_recursion) {
return lines.join("\n");
}
},
set_delimiters: function(delimiters) {
var dels = delimiters.split(" ");
this.otag = this.escape_regex(dels[0]);
this.ctag = this.escape_regex(dels[1]);
},
escape_regex: function(text) {
// thank you Simon Willison
if(!arguments.callee.sRE) {
var specials = [
'/', '.', '*', '+', '?', '|',
'(', ')', '[', ']', '{', '}', '\\'
];
arguments.callee.sRE = new RegExp(
'(\\' + specials.join('|\\') + ')', 'g'
);
}
return text.replace(arguments.callee.sRE, '\\$1');
},
/*
find `name` in current `context`. That is find me a value
from the view object
*/
find: function(name, context) {
name = this.trim(name);
// Checks whether a value is thruthy or false or 0
function is_kinda_truthy(bool) {
return bool === false || bool === 0 || bool;
}
var value;
if(is_kinda_truthy(context[name])) {
value = context[name];
} else if(is_kinda_truthy(this.context[name])) {
value = this.context[name];
}
if(typeof value === "function") {
return value.apply(context);
}
if(value !== undefined) {
return value;
}
// silently ignore unkown variables
return "";
},
// Utility methods
/* includes tag */
includes: function(needle, haystack) {
return haystack.indexOf(this.otag + needle) != -1;
},
/*
Does away with nasty characters
*/
escape: function(s) {
s = String(s === null ? "" : s);
return s.replace(/&(?!\w+;)|["'<>\\]/g, function(s) {
switch(s) {
case "&": return "&amp;";
case "\\": return "\\\\";
case '"': return '&quot;';
case "'": return '&#39;';
case "<": return "&lt;";
case ">": return "&gt;";
default: return s;
}
});
},
// by @langalex, support for arrays of strings
create_context: function(_context, opts) {
if(this.is_object(_context)) {
if (this.pragmas["ARRAY-ORDINALS"] && opts) {
_context['first?'] = opts.first || false;
_context['last?'] = opts.last || false;
}
return _context;
} else {
var iterator = ".";
if(this.pragmas["IMPLICIT-ITERATOR"]) {
iterator = this.pragmas["IMPLICIT-ITERATOR"].iterator;
}
var ctx = {};
ctx[iterator] = _context;
if (this.pragmas["ARRAY-ORDINALS"] && opts){
ctx['first?'] = opts.first || false;
ctx['last?'] = opts.last || false;
}
return ctx;
}
},
is_object: function(a) {
return a && typeof a == "object";
},
is_array: function(a) {
return Object.prototype.toString.call(a) === '[object Array]';
},
/*
Gets rid of leading and trailing whitespace
*/
trim: function(s) {
return s.replace(/^\s*|\s*$/g, "");
},
/*
Why, why, why? Because IE. Cry, cry cry.
*/
map: function(array, fn) {
if (typeof array.map == "function") {
return array.map(fn);
} else {
var r = [];
var l = array.length;
for(var i = 0; i < l; i++) {
r.push(fn(array[i]));
}
return r;
}
}
};
return({
name: "mustache.js",
version: "0.3.1-dev",
/*
Turns a template and view into HTML
*/
to_html: function(template, view, partials, send_fun) {
var renderer = new Renderer();
if(send_fun) {
renderer.send = send_fun;
}
renderer.render(template, view, partials);
if(!send_fun) {
return renderer.buffer.join("\n");
}
}
});
}();
exports.name = Mustache.name;
exports.version = Mustache.version;
exports.to_html = function() {
return Mustache.to_html.apply(this, arguments);
};

View File

@ -142,7 +142,7 @@
longname = longname.replace( /\.prototype\.?/g, '#' );
var parts = longname?
longname.match( /^(:?(.+)([#.~]))?(.+?)$/ ).reverse()
(longname.match( /^(:?(.+)([#.~]))?(.+?)$/ ) || []).reverse()
: [''];
var name = parts[0],

View File

@ -14,7 +14,7 @@
* @class
* @mixes module:common/events.*
*
* @example
* @example <caption>Create a new parser.</caption>
* var jsdocParser = new (require('jsdoc/src/parser').Parser)();
*/
exports.Parser = function() {
@ -25,7 +25,7 @@
/**
* Parse the given source files for JSDoc comments.
* @param {Array<string>} sourceFiles
* @param {Array.<string>} sourceFiles An array of filepaths to the JavaScript sources.
* @param {string} [encoding=utf8]
*
* @fires jsdocCommentFound
@ -34,7 +34,7 @@
* @fires fileBegin
* @fires fileComplete
*
* @example
* @example <caption>Parse two source files.</caption>
* var myFiles = ['file1.js', 'file2.js'];
* var docs = jsdocParser.parse(myFiles);
*/
@ -127,6 +127,7 @@
/**
* Given a node, determine what the node is a member of.
* @param {astnode} node
* @returns {string} The long name of the node that this is a member of.
*/
exports.Parser.prototype.astnodeToMemberof = function(node) {
var memberof = {};
@ -479,8 +480,8 @@
Fired whenever the parser encounters a JSDoc comment in the current source code.
@event jsdocCommentFound
@memberof module:jsdoc/src/parser.Parser
@param e
@param e.comment The text content of the JSDoc comment
@param e.lineno The line number associated with the found comment.
@param e.filename The file name associated with the found comment.
@param {event} e
@param {string} e.comment The text content of the JSDoc comment
@param {number} e.lineno The line number associated with the found comment.
@param {string} e.filename The file name associated with the found comment.
*/

View File

@ -1,17 +1,14 @@
/**
@module jsdoc/tag/dictionary
@overview
@author Michael Mathews <micmath@gmail.com>
@license Apache License 2.0 - See file 'LICENSE.md' in this project.
*/
(function() {
var _synonyms = {},
_definitions = {},
_namespaces = [],
dictionary;
_namespaces = [];
/** @constructor */
function TagDefinition(title, etc) {
function _TagDefinition(title, etc) {
etc = etc || {};
this.title = dictionary.normalise(title);
@ -23,14 +20,16 @@
}
}
TagDefinition.prototype.synonym = function(synonymName) {
_TagDefinition.prototype.synonym = function(synonymName) {
_synonyms[synonymName.toLowerCase()] = this.title;
return this; // chainable
}
dictionary = {
/** @exports jsdoc/tag/dictionary */
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);
@ -39,6 +38,7 @@
return _definitions[title];
},
/** @function */
lookUp: function(title) {
title = dictionary.normalise(title);
@ -49,10 +49,12 @@
return false;
},
/** @function */
isNamespace: function(kind) {
return ( ~ _namespaces.indexOf(kind) );
},
/** @function */
normalise: function(title) {
canonicalName = title.toLowerCase();

View File

@ -58,15 +58,17 @@
dictionary.defineTag('class', {
onTagged: function(doclet, tag) {
doclet.addTag('kind', 'class');
// handle special case where both @class and @constructor tags exist in same doclet
if (tag.originalTitle === 'class') {
if ( /@construct(s|or)\b/i.test(doclet.comment) ) {
var looksLikeDesc = (tag.value || '').match(/\S+\s+\S+/); // multiple words after @class?
if ( looksLikeDesc || /@construct(s|or)\b/i.test(doclet.comment) ) {
doclet.classdesc = tag.value; // treat the @class tag as a @classdesc tag instead
return;
}
}
doclet.addTag('kind', 'class');
setDocletNameToValue(doclet, tag);
}
})
@ -97,8 +99,7 @@
mustHaveValue: true,
onTagged: function(doclet, tag) {
var ownerClassName = firstWordOf(tag.value);
doclet.addTag('alias', ownerClassName/* + '.constructor'*/);
//doclet.addTag('memberof', ownerClassName);
doclet.addTag('alias', ownerClassName);
doclet.addTag('kind', 'class');
}
});
@ -172,7 +173,7 @@
doclet.addTag('alias', modName);
doclet.addTag('kind', 'module');
doclet.addTag('undocumented');
//doclet.addTag('undocumented');
}
})
.synonym('defines');

View File

@ -1,7 +1,7 @@
{
"name": "jsdoc",
"version": "3.0.0beta1",
"revision": "2011-02-11-2113",
"revision": "2011-02-24-1703",
"description": "An automatic documentation generator for javascript.",
"keywords": [ "documentation", "javascript" ],
"licenses": [

View File

@ -1,7 +1,10 @@
(function() {
var Mustache = require('janl/mustache'),
var template = require('underscore/template'),
fs = require('fs');
template.settings.evaluate = /<\?js([\s\S]+?)\?>/g;
template.settings.interpolate = /<\?js=([\s\S]+?)\?>/g;
/**
@global
@ -9,27 +12,49 @@
@param {object} opts
*/
publish = function(data, opts) {
var out = '';
var out = '',
containerTemplate = template.render(fs.read(BASEDIR + 'templates/default/tmpl/container.tmpl'));
var helpers = {
linkTo: function() {
return function(text, render) {
var linkTo,
text = render(text);
if ( !data.find({longname: text}).length ) { return text; }
linkTo = text.replace(/#/g, '%23');
return '<a href="#' + linkTo + '">' + text + '</a>';
}
function render(tmpl, partialData) {
var renderFunction = arguments.callee.cache[tmpl];
if (!renderFunction) {
renderFunction = arguments.callee.cache[tmpl] = template.render(fs.read(BASEDIR + 'templates/default/tmpl/'+tmpl));
}
};
partialData.render = arguments.callee;
partialData.find = find;
partialData.htmlsafe = htmlsafe;
return renderFunction.call(partialData, partialData);
}
render.cache = {};
function find(spec) {
return data.get( data.find(spec) );
}
function htmlsafe(str) {
return str.replace(/</g, '&lt;');
}
// var helpers = {
// linkTo: function() {
// return function(text, render) {
// var linkTo,
// text = render(text);
//
// if ( !data.find({longname: text}).length ) { return text; }
//
// linkTo = text.replace(/#/g, '%23');
// return '<a href="#' + linkTo + '">' + text + '</a>';
// }
// }
// };
function summarize(doclet) {
var desc = doclet.description || '';
desc = desc.replace(/<\/?p>/gi, ''); // full text may be HTML, remove P wrapper
desc = trim(desc);
desc = desc.trim();
var m;
@ -37,132 +62,108 @@
doclet.summary = m[1];
doclet.description = m[2]? m[2] : '';
}
doclet.signature = '';
doclet.attribs = '';
}
function trim(text) {
return text.replace(/^\s+|\s+$/g, '');
}
data.remove({undocumented: true});
var packageInfo = (data.get( data.find({kind: 'package'}) ) || []) [0];
// add template helpers
data.forEach(function(doclet) {
doclet.hasParams = doclet.params && doclet.params.length > 0;
doclet.hasReturns = doclet.returns && doclet.returns.length > 0;
doclet.hasBorrowed = doclet.borrowed && doclet.borrowed.length > 0;
doclet.hasExceptions = doclet.exceptions && doclet.exceptions.length > 0;
doclet.hasExamples = doclet.examples && doclet.examples.length > 0;
summarize(doclet);
});
data.orderBy(['longname', 'kind']);
var containerTemplate = fs.read(BASEDIR + 'templates/default/tmpl/container.mustache');
var partials = {
paramsTemplate: fs.read(BASEDIR + 'templates/default/tmpl/params.mustache'),
returnsTemplate: fs.read(BASEDIR + 'templates/default/tmpl/returns.mustache'),
methodsTemplate: fs.read(BASEDIR + 'templates/default/tmpl/methods.mustache'),
propertiesTemplate: fs.read(BASEDIR + 'templates/default/tmpl/properties.mustache'),
examplesTemplate: fs.read(BASEDIR + 'templates/default/tmpl/example.mustache'),
namespacesTemplate: fs.read(BASEDIR + 'templates/default/tmpl/namespaces.mustache'),
classesTemplate: fs.read(BASEDIR + 'templates/default/tmpl/classes.mustache'),
exceptionsTemplate: fs.read(BASEDIR + 'templates/default/tmpl/exceptions.mustache')
};
var topLevels = {
projects: [],
globals: [],
modules: [],
namespaces: [],
classes: [],
mixins: []
};
topLevels.globals = data.get( data.find({memberof: {isUndefined: true}}) );
var modules = data.get( data.find({kind: 'module'}) ),
classes = data.get( data.find({kind: 'class'}) ),
namespaces = data.get( data.find({kind: 'namespace'}) );
modules.forEach(function(m) {
m.methods = data.get( data.find({kind: 'function', memberof: m.longname}) );
m.hasMethods = (m.methods && m.methods.length > 0);
m.methods.forEach(prepareFunc);
m.properties = data.get( data.find({kind: 'property', memberof: m.longname}) );
m.hasProperties = (m.properties && m.properties.length > 0);
m.properties.forEach(prepareProp);
m.namespaces = data.get( data.find({kind: 'namespace', memberof: m.longname}) );
m.hasNamespaces = (m.namespaces && m.namespaces.length > 0);
m.namespaces.forEach(prepareNs);
m.classes = data.get( data.find({kind: 'class', memberof: m.longname}) );
m.hasClasses = (m.classes && m.classes.length > 0);
// TODO: namespaces
});
classes.forEach(function(c) {
c.methods = data.get( data.find({kind: 'function', memberof: c.longname}) );
c.hasMethods = (c.methods && c.methods.length > 0);
prepareFunc(c);
c.hasConstructor = true;
c.methods.forEach(prepareFunc);
c.properties = data.get( data.find({kind: 'property', memberof: c.longname}) );
c.hasProperties = (c.properties && c.properties.length > 0);
c.properties.forEach(prepareProp);
c.namespaces = data.get( data.find({kind: 'namespace', memberof: c.longname}) );
c.hasNamespaces = (c.namespaces && c.namespaces.length > 0);
c.namespaces.forEach(prepareNs);
c.classes = data.get( data.find({kind: 'class', memberof: c.longname}) );
c.hasClasses = (c.classes && c.classes.length > 0);
});
namespaces.forEach(function(n) {
n.methods = data.get( data.find({kind: 'function', memberof: n.longname}) );
n.hasMethods = (n.methods && n.methods.length > 0);
//prepareNs(n);
n.methods.forEach(prepareFunc);
n.properties = data.get( data.find({kind: 'property', memberof: n.longname}) );
n.hasProperties = (n.properties && n.properties.length > 0);
n.properties.forEach(prepareProp);
n.namespaces = data.get( data.find({kind: 'namespace', memberof: n.longname}) );
n.hasNamespaces = (n.namespaces && n.namespaces.length > 0);
n.namespaces.forEach(prepareNs);
n.classes = data.get( data.find({kind: 'class', memberof: n.longname}) );
n.hasClasses = (n.classes && n.classes.length > 0);
});
function prepareFunc(f) {
function addSignatureParams(f) {
var pnames = [];
if (f.params) {
f.params.forEach(function(p) {
if (p.name && p.name.indexOf('.') === -1) { pnames.push(p.name); }
if (p.name && p.name.indexOf('.') === -1) {
if (p.optional) { pnames.push('['+p.name+']'); }
else { pnames.push(p.name); }
}
});
}
f.synopsis = (f.kind === 'class'? 'new ' : '') + f.name+'('+pnames.join(', ')+')'
f.hasParams = (f.params && f.params.length > 0);
f.hasReturns = (f.returns && f.returns.length > 0);
f.signature = (f.signature || '') + '('+pnames.join(', ')+')';
}
function prepareProp(p) {
function addSignatureReturns(f) {
var returnTypes = [];
if (f.returns) {
f.returns.forEach(function(r) {
if (r.type && r.type.names) {
returnTypes = r.type.names;
}
});
}
f.signature = (f.signature || '') + '<span class="type-signature">'+htmlsafe(returnTypes.length? ' &#8658; '+returnTypes.join('|') : '')+'</span>';
}
function prepareNs(p) {
function addSignatureType(f) {
var types = [];
if (f.type && f.type.names) {
types = f.type.names;
}
f.signature = (f.signature || '') + '<span class="type-signature">'+htmlsafe(types.length? ' :'+types.join('|') : '')+'</span>';
}
function addAttribs(f) {
var attribs = [];
if (f.access && f.access !== 'public') {
attribs.push(f.access);
}
if (f.scope && f.scope !== 'instance') {
if (f.kind == 'function' || f.kind == 'property') attribs.push(f.scope);
}
if (f.readonly === true) {
if (f.kind == 'property') attribs.push('readonly');
}
f.attribs = '<span class="type-signature">'+htmlsafe(attribs.length? '<'+attribs.join(', ')+'> ' : '')+'</span>';
}
data.remove({undocumented: true});
var packageInfo = (data.get( data.find({kind: 'package'}) ) || []) [0];
data.forEach(function(doclet) {
summarize(doclet);
if (doclet.kind === 'function' || doclet.kind === 'class') {
addSignatureParams(doclet);
addSignatureReturns(doclet);
addAttribs(doclet);
}
if (doclet.kind === 'property') {
addSignatureType(doclet);
addAttribs(doclet)
}
if (doclet.examples) {
doclet.examples = doclet.examples.map(function(example) {
var caption, code;
if (example.match(/^\s*<caption>([\s\S]+?)<\/caption>(\s*[\n\r])([\s\S]+)$/i)) {
caption = RegExp.$1;
code = RegExp.$3;
}
return {
caption: caption || '',
code: code || example
};
});
}
});
data.orderBy(['longname', 'kind', 'version', 'since']);
// kinds of containers
var globals = data.get( data.find({kind: ['property', 'function'], memberof: {isUndefined: true}}) ),
modules = data.get( data.find({kind: 'module'}) ),
namespaces = data.get( data.find({kind: 'namespace'}) );
var outdir = opts.destination;
if (packageInfo) {
outdir += '/' + packageInfo.name + '/' + packageInfo.version + '/';
@ -172,36 +173,53 @@
// copy static files to outdir
var fromDir = BASEDIR + 'templates/default/static',
staticFiles = fs.ls(fromDir, 3);
staticFiles.forEach(function(fileName) {
var toDir = fs.toDir(fileName.replace(fromDir, outdir));
fs.mkPath(toDir);
fs.copyFile(fileName, toDir);
});
// containers
generate('Modules', modules, 'modules.html');
generate('Classes', classes, 'classes.html');
generate('Namespaces', namespaces, 'namespaces.html');
//dump(classes)
//generate('Globals', globals, 'globals.html');
//generate('Modules', modules, 'modules.html');
//generate('Classes', classes, 'classes.html');
//generate('Namespaces', namespaces, 'namespaces.html');
var urlToLongname = {},
longnameToUrl = {};
var classes = data.get(data.find({kind: 'class'}));
for (var i = 0, len = classes.length; i < len; i++) {
var longname = classes[i].longname,
urlSafe = longname.replace(/[^$a-z0-9._-]/gi, '_');
// bidirectional lookups: url <=> longname
urlToLongname[urlSafe] = longname;
longnameToUrl[longname] = urlSafe;
}
for (var longname in longnameToUrl) {
var classes = data.get( data.find({kind: 'class', longname: longname}) );
generate(classes[0].kind+': '+classes[0].name, classes, longnameToUrl[longname]+'.html');
}
function generate(title, docs, filename) {
var data = {
title: title,
docs: docs,
// helpers
render: render,
find: find,
htmlsafe: htmlsafe
};
var path = outdir + '/' + filename,
html = Mustache.to_html(
containerTemplate,
{
title: title,
docs: docs,
linkTo: helpers.linkTo
},
partials
);
html = containerTemplate.call(data, data);
fs.write(path, html)
}
}
})();

View File

@ -1,233 +1,155 @@
.kind { font-style: italic; }
.constructor, .mixin, .namespace
body
{
font-weight: bold;
color: #780000;
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Verdana, Tahoma, sans-serif;
font-size: 13px;
color: #000;
background-color: #E2ECF0;
}
.property { color: #666; }
.function { color: #666; }
.access { color: #666; }
h1, h2, h3, h4, h5, h6
header
{
font-family: "Bitstream Vera Sans", "DejaVu Sans", "Trebuchet MS", Verdana, "Verdana Ref", sans serif;
font-weight: bold;
display: block;
/*border-bottom: 1px solid #ddd;*/
padding: 6px 4px;
}
.page-title
{
font-family: "Bitstream Vera Sans", "DejaVu Sans", "Trebuchet MS", Verdana, "Verdana Ref", sans serif;
font-size: 3.5em;
font-weight: bolder;
margin: 0 0 0.1em;
color: #FFF;
}
.section-title
{
font-size: 2.5em;
margin: 0;
color: #798D3E;
.class-description {
font-style: italic;
font-family: Palatino, "Palatino Linotype", serif;
font-size: 18px;
}
section
{
border: 1px solid #ccc;
border-radius: 15px;
-moz-border-radius: 8px;
display: block;
padding: 0.75em 0.5em 0.5em 1em;
margin: 0.5em 0.5em 1em 1em;
margin: 14px 28px;
background-color: #fff;
padding: 12px 24px;
-moz-border-radius: 7px;
border-radius: 7px
}
h1
{
font-size: 32px;
font-weight: bold;
letter-spacing: -0.03em;
margin: 6px 0 9px 0;
}
h2
{
font-size: 22px;
font-weight: bold;
letter-spacing: -0.03em;
margin: 6px 0 3px 0;
}
h3
{
font-size: 20px;
font-weight: bold;
letter-spacing: -0.03em;
margin-top: 16px;
margin: 6px 0 3px 0;
}
h4
{
font-size: 18px;
font-weight: bold;
letter-spacing: -0.03em;
margin-top: 16px;
margin: 18px 0 3px 0;
color: #A35A00;
}
h5
{
font-size: 16px;
font-weight: bold;
letter-spacing: -0.03em;
margin: 6px 0 3px 0;
}
h6
{
font-size: 13px;
letter-spacing: -0.03em;
margin: 6px 0 3px 0;
font-style: italic;
}
.ancestor-name {
color: #ccc;
}
.type-signature {
color: #aaa;
}
/*.description {
font-family: Palatino, "Palatino Linotype", serif;
font-size: 14px;
}*/
.code-caption
{
font-style: italic;
font-family: Palatino, "Palatino Linotype", serif;
font-size: 14px;
margin: 0;
}
.sh_sourceCode
{
border: 1px solid #ddd;
width: 80%;
}
.sh_sourceCode code
{
font-family: Consolas, "Lucida Console", Monaco, monospace;
font-size: 12px;
line-height: 18px;
display: block;
padding: 4px 12px;
margin: 0;
background-color: #fff;
color: #000;
border-left: 3px #1C02A3 solid;
}
.subsection-title
.params
{
font-size: 1.9em;
margin: 0.5em 0 1em;
color: #000;
border-spacing: 0;
border: 0;
border-collapse: collapse;
}
.method-title, .class-title
.params .name { color: #1C02A3; }
.params td, .params th
{
font-size: 1.7em;
margin: 0 0 1em 1em;
color: #7B1A3F;
border: 1px solid #ddd;
margin: 0px;
text-align: left;
vertical-align: top;
padding: 4px 6px;
display: table-cell;
}
.detail-list { list-style-type: none; }
html
.params thead tr
{
/* stops IE resizing fonts by a massive amount */
font-size: 100%;
}
body
{
/* fixes monospace font sizes in webkit */
/* following line is picked up by IE6 & 7, which cannot resize pixel-based font sizes */
*font-size: 62.5%;
font-size: 0.8em;
font-family: verdana, sans-serif;
/*overflow: hidden;*/
zoom: 1;
/*background: url(images/pagebg.png) 0 73px repeat-x;*/
color: #eee;
background-color: #22252a;
}
a:link, a:visited
{
color: #356a8b;
text-decoration: none;
border-bottom: 1px dotted #356a8b;
}
a:hover, a:active
{
color: #298FB2;
border-color: #298FB2;
border-bottom-style: solid;
}
a.image { border: 0; }
p
{
margin: 0 0 1em 0;
line-height: 1.5;
}
code { font-family: Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace; }
dl.params dt
{
border-top: 1px solid #b2b1b1;
color: #298FB2;
background-color: #ddd;
font-weight: bold;
padding-top: 8px;
margin-bottom: 5px;
font-size: 1.1em;
float: none;
overflow: visible;
zoom: 0;
}
dl.params dt.first
.params .params thead tr
{
border-top: none;
padding-top: 0;
margin-top: 0;
}
dl.params dd
{
border-width: 0;
margin-bottom: 16px;
}
dl.param-properties
{
font-style: italic;
overflow: hidden;
zoom: 1;
font-size: 0.9em;
margin: 1em 0;
}
dl.param-properties dt span,
dl.param-properties dd
{
color: #555;
float: left;
margin: 0;
padding: 0;
display: inline;
margin-bottom: 5px;
font-size: 1em;
border: none;
}
dl.param-properties dt
{
clear: both;
display: inline;
font-size: 1em;
padding: 0;
float: none;
overflow: visible;
zoom: 0;
}
dl.param-properties dt span
{
width: 85px;
clear: both;
}
.no-docs
{
font-style: italic;
font-weight: lighter;
color: #666;
}
.property { margin-left: 30px; }
.property-head
{
margin-left: -20px;
display: block;
line-height: 1.2em;
}
.property-name
{
float: left;
margin: 0;
padding: 0 10px 0 0;
font-style: italic;
background-color: #fff;
font-weight: bold;
font-size: 1.2em;
color: #4782B5;
}
.property-summary
{
color: #999;
font-size: 1em;
}
.property-details
{
clear: both;
overflow: hidden;
}
.property-details dt
{
font-weight: bold;
margin-bottom: 4px;
padding-left: 10px;
clear: left;
float: left;
}
.property-details dd { padding-left: 60px; }
.property-deprecated { text-decoration: line-through; }
.example-code
{
padding: 2px 2px 2px 10px;
margin-right: 24px;
color: #fff;
background-color: #444;
border-radius: 2px;
-moz-border-radius: 2px;
}
.yesDef { text-indent: -5000px; }
.params th { border-right: 1px solid #aaa; }
.params thead .last { border-right: 1px solid #ddd; }

View File

@ -1,26 +1,150 @@
.sh_sourceCode {
.sh_sourceCode {
background-color: #ffffff;
color: #000000;
font-weight: normal;
font-style: normal;
}
.sh_sourceCode .sh_symbol , .sh_sourceCode .sh_cbracket {
color: #fff;
.sh_sourceCode .sh_keyword {
color: #000000;
font-weight: bold;
font-style: normal;
}
.sh_sourceCode .sh_keyword
{
font-style: italic;
color: #ECDDAA;
.sh_sourceCode .sh_type {
color: #a52a2a;
font-weight: bold;
font-style: normal;
}
.sh_sourceCode .sh_string, .sh_sourceCode .sh_regexp, .sh_sourceCode .sh_number,
.sh_sourceCode .sh_specialchar
{
color: #B0C4DE;
.sh_sourceCode .sh_string {
color: #006400;
font-weight: normal;
font-style: normal;
}
.sh_sourceCode .sh_comment {
color: #777;
.sh_sourceCode .sh_regexp {
color: #006400;
font-weight: normal;
font-style: normal;
}
.sh_sourceCode .sh_specialchar {
color: #2e8b57;
font-weight: normal;
font-style: normal;
}
.sh_sourceCode .sh_comment {
color: #000000;
font-weight: normal;
font-style: italic;
}
.sh_sourceCode .sh_number {
color: #006400;
font-weight: normal;
font-style: normal;
}
.sh_sourceCode .sh_preproc {
color: #27408b;
font-weight: normal;
font-style: normal;
}
.sh_sourceCode .sh_symbol {
color: #000000;
font-weight: bold;
font-style: normal;
}
.sh_sourceCode .sh_function {
color: #000000;
font-weight: normal;
font-style: normal;
}
.sh_sourceCode .sh_cbracket {
color: #000000;
font-weight: bold;
font-style: normal;
}
.sh_sourceCode .sh_url {
color: #006400;
font-weight: normal;
font-style: normal;
}
.sh_sourceCode .sh_date {
color: #000000;
font-weight: bold;
font-style: normal;
}
.sh_sourceCode .sh_time {
color: #000000;
font-weight: bold;
font-style: normal;
}
.sh_sourceCode .sh_file {
color: #000000;
font-weight: bold;
font-style: normal;
}
.sh_sourceCode .sh_ip {
color: #006400;
font-weight: normal;
font-style: normal;
}
.sh_sourceCode .sh_name {
color: #006400;
font-weight: normal;
font-style: normal;
}
.sh_sourceCode .sh_variable {
color: #dda0dd;
font-weight: bold;
font-style: normal;
}
.sh_sourceCode .sh_oldfile {
color: #2e8b57;
font-weight: normal;
font-style: normal;
}
.sh_sourceCode .sh_newfile {
color: #006400;
font-weight: normal;
font-style: normal;
}
.sh_sourceCode .sh_difflines {
color: #000000;
font-weight: bold;
font-style: normal;
}
.sh_sourceCode .sh_selector {
color: #dda0dd;
font-weight: bold;
font-style: normal;
}
.sh_sourceCode .sh_property {
color: #000000;
font-weight: bold;
font-style: normal;
}
.sh_sourceCode .sh_value {
color: #006400;
font-weight: normal;
font-style: normal;
}

View File

@ -1,10 +0,0 @@
<dl class="classes">
{{#classes}}
<dt class="furtherDetailHeading"">
<h4 class="class-title"><a href="classes.html#{{longname}}">{{name}}</a></h4>
</dt>
<dd>
{{#summary}}<p class="shortDesc">{{{summary}}}</p>{{/summary}}
</dd>
{{/classes}}
</dl>

View File

@ -1,82 +0,0 @@
{{%ARRAY-ORDINALS}}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: {{title}}</title>
<script src="http://shjs.sourceforge.net/sh_main.min.js"> </script>
<script src="http://shjs.sourceforge.net/lang/sh_javascript.min.js"> </script>
<link type="text/css" rel="stylesheet" href="styles/node-dark.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<h1 class="page-title">{{title}}</h1>
{{#docs}}
<section>
<h2 class="section-title" id="{{longname}}">{{kind}}: {{name}}</h2>
{{#classdesc}}
<div class="description">{{classdesc}}</div>
{{/classdesc}}
{{#summary}}
<div class="summary">{{summary}}</div>
{{/summary}}
{{#description}}
<div class="description">{{description}}</div>
{{/description}}
{{#hasConstructor}}
<h3 class="subsection-title">Constructor:</h3>
<dl class="constructor">
{{>methodsTemplate}}
</dl>
{{/hasConstructor}}
{{#hasClasses}}
<h3 class="subsection-title">Classes:</h3>
{{>classesTemplate}}
{{/hasClasses}}
{{#hasNamespaces}}
<h3 class="subsection-title">Namespaces:</h3>
{{>namespacesTemplate}}
{{/hasNamespaces}}
<h3 class="subsection-title">Methods:</h3>
{{#hasMethods}}
<dl class="methods">
{{#methods}}
{{>methodsTemplate}}
{{/methods}}
</dl>
{{/hasMethods}}
{{^hasMethods}}
<p class="no-docs">The {{name}} {{kind}} has no documented methods.</p>
{{/hasMethods}}
<h3 class="subsection-title">Properties:</h3>
{{#hasProperties}}
<dl class="properties">
{{#properties}}
{{>propertiesTemplate}}
{{/properties}}
</dl>
{{/hasProperties}}
{{^hasProperties}}
<p class="no-docs">The {{name}} {{kind}} has no documented properties.</p>
{{/hasProperties}}
</section>
{{/docs}}
<script> sh_highlightDocument(); </script>
</body>
</html>

View File

@ -0,0 +1,176 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: <?js= title ?></title>
<script src="http://shjs.sourceforge.net/sh_main.min.js"> </script>
<script src="http://shjs.sourceforge.net/lang/sh_javascript.min.js"> </script>
<link type="text/css" rel="stylesheet" href="styles/node-dark.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<h1 class="page-title"><?js= title ?></h1>
<?js
docs.forEach(function(doc, i) {
?>
<section>
<header>
<?js
if (doc.classdesc) {
print('<p class="class-description">'+doc.classdesc+'</p>');
}
?>
<!--
var displayname = htmlsafe(doc.longname).replace(doc.name, '</span><b>'+doc.name+'</b>');
/*print('<span class="ancestor-name">' + displayname + doc.signature);*/
-->
</header>
<div class="accordian-content">
<?js
if (doc.kind === 'class') {
?>
<?js
print(render('method.tmpl', doc));
} ?>
<?js
if (doc.augments && doc.augments.length && doc.augments.forEach) {
?>
<h3 class="subsection-title">Extends</h3>
<ul><?js
doc.augments.forEach(function(a) {
?>
<li><?js= a ?></li>
<?js
});
?></ul>
<?js } ?>
<?js
if (doc.borrowed && doc.borrowed.length && doc.borrowed.forEach) {
?>
<h3 class="subsection-title">Borrows From</h3>
<ul><?js
doc.borrowed.forEach(function(b) {
?>
<li><?js= b.from ?></li>
<?js
});
?></ul>
<?js } ?>
<?js
/* link to any classes in this container */
var classes = find({kind: 'class', memberof: doc.longname});
if (classes && classes.length && classes.forEach) {
?>
<h3 class="subsection-title">Classes</h3>
<dl><?js
classes.forEach(function(c) {
?>
<dt><a href="classes.html#<?js= c.longname ?>"><?js= c.name ?></a></dt>
<dd><?js if (c.summary) print(c.summary); ?></dd>
<?js
});
?></dl>
<?js } ?>
<?js
/* link to any namespaces in this container */
var namespaces = find({kind: 'namespace', memberof: doc.longname});
if (namespaces && namespaces.length && namespaces.forEach) {
?>
<h3 class="subsection-title">Namespaces</h3>
<dl><?js
namespaces.forEach(function(n) {
?>
<dt><a href="namespaces.html#<?js= n.longname ?>"><?js= n.name ?></a></dt>
<dd><?js if (n.summary) print(n.summary); ?></dd>
<?js
});
?></dl>
<?js } ?>
<?js
/* list any properties in this container */
var properties = find({kind: 'property', memberof: doc.longname});
if (properties && properties.length && properties.forEach) {
?>
<h3 class="subsection-title">Properties</h3>
<dl><?js
properties.forEach(function(p) {
print(render('properties.tmpl', p));
});
?></dl>
<?js } ?>
<?js
/* list any methods in this container */
var methods = find({kind: 'function', memberof: doc.longname});
if (title === 'Globals') {
methods = find({kind: 'function', memberof: {isUndefined: true}});
}
if (methods && methods.length && methods.forEach) {
?>
<h3 class="subsection-title">Methods</h3>
<dl><?js
methods.forEach(function(m) {
print(render('method.tmpl', m));
});
?></dl>
<?js } ?>
<?js
/* list any events in this container */
var events = find({kind: 'event', memberof: doc.longname});
if (events && events.length && events.forEach) {
?>
<h3 class="subsection-title">Events</h3>
<dl><?js
events.forEach(function(e) {
print(render('method.tmpl', e));
});
?></dl>
<?js } ?>
</div>
</section>
<?js }); ?>
<script> sh_highlightDocument(); </script>
</body>
</html>

View File

@ -1,12 +0,0 @@
<dt>
<h5>Example</h5>
</dt>
<dd>
{{#examples}}
<br clear="both">
<div class="example-code">
<pre class="sh_javascript"><code>{{.}}</code></pre>
</div>
<br clear="both">
{{/examples}}
</dd>

View File

@ -0,0 +1,2 @@
<pre><code><?js= this ?></code></pre>

View File

@ -0,0 +1,10 @@
<?js
this.forEach(function(example) {
if (example.caption) {
?>
<p class="code-caption"><?js= example.caption ?></p>
<?js } ?>
<pre class="sh_javascript"><code><?js= example.code ?></code></pre>
<?js
});
?>

View File

@ -1,28 +0,0 @@
<dl class="params detail-list">
{{#exceptions}}
<dt{{#first?}} class="first"{{/first?}}></dt>
<dd>
<dl class="param-properties">
{{#type}}
<dt>
<span>Type</span>
</dt>
<dd>
{{#names}}
<span class="param-type">{{#linkTo}}{{.}}{{/linkTo}}</span>{{^last?}} | {{/last?}}{{#last?}} {{/last?}}
{{/names}}
</dd>
{{/type}}
</dl>
{{#description}}
<div class="param-desc">
{{description}}
</div>
{{/description}}
</dd>
{{/exceptions}}
</dl>

View File

@ -0,0 +1,28 @@
<li>
<?js if (this.description) { ?>
<div class="param-desc">
<?js= description ?>
</div>
<?js } ?>
<?js
if (typeof this.names !== 'undefined') {
?>
<dl>
<dt>
Type
</dt>
<dd>
<?js
this.names.forEach(function(name, i) {
?>
<span class="param-type"><?js= name ?></span> <?js if (i < this.names.length-1) print('|'); ?>
<?js
});
?>
</dd>
</dl>
<?js
}
?>
</li>

View File

@ -0,0 +1,3 @@
<li>
<?js= this ?>
</li>

View File

@ -1,189 +0,0 @@
{{%ARRAY-ORDINALS}}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc Index</title>
<style type="text/css">
.kind { font-style: italic; }
.class, .mixin, .namespace
{
font-weight: bold;
color: #780000;
}
.property { color: #666; }
.function { color: #666; }
.access { color: #666; }
.detail-list {
list-style-type:none;
}
html {
/* stops IE resizing fonts by a massive amount */
font-size: 100%
}
body {
/* pixes monospace font sizes in webkit */
font-size: 10px;
/* following line is picked up by IE6 & 7, which cannot resize pixel-based font sizes */
*font-size: 62.5%;
}
body {
font-size: 0.8em;
font-family: verdana, sans-serif;
/*overflow: hidden;*/
zoom: 1;
/*background: url(images/pagebg.png) 0 73px repeat-x;*/
color: #333333;
}
a:link, a:visited {
color: #356a8b;
text-decoration: none;
border-bottom: 1px dotted #356a8b;
}
a:hover, a:active {
color: #298FB2;
border-color: #298FB2;
border-bottom-style: solid;
}
a.image {
border: 0;
}
h1 {
font-size: 2em;
font-family: arial, sans-serif;
}
h2 {
font-size: 1.7em;
margin: 0 0 1em 0;
font-family: arial, sans-serif;
}
h3 {
font-size: 1.4em;
margin: 0.4em 0;
font-family: arial, sans-serif;
color: #4e4e4e;
}
h4 {
margin: 1em 0;
color: #298FB2;
}
h5 {
margin: 1em 0;
}
p {
margin: 0 0 1em 0;
line-height: 1.5;
}
dl.params dt {
border-top: 1px solid #b2b1b1;
color: #298FB2;
font-weight: bold;
padding-top: 8px;
margin-bottom: 5px;
font-size: 1.1em;
float: none;
overflow: visible;
zoom: 0;
}
dl.params dt.first {
border-top: none;
padding-top: 0;
margin-top: 0;
}
dl.params dd {
border-width: 0;
margin-bottom: 16px;
}
dl.param-properties {
font-style: italic;
overflow: hidden;
zoom: 1;
font-size: 0.9em;
margin: 1em 0;
}
dl.param-properties dt span,
dl.param-properties dd {
color: #555;
float: left;
margin: 0;
padding: 0;
display: inline;
margin-bottom: 5px;
font-size: 1em;
border: none;
}
dl.param-properties dt {
clear: both;
display: inline;
font-size: 1em;
padding: 0;
float: none;
overflow: visible;
zoom: 0;
}
dl.param-properties dt span {
width: 85px;
clear: both;
}
dl.param-properties dd.yesDef {
text-indent: -5000px;
}
</style>
</head>
<body>
<h1>{{title}}</h1>
<dl>
{{#docs}}
<h2 class="symbol-head" id="{{longname}}">
{{#kind}}<span class="kind {{kind}}">{{kind}}</span> {{/kind}}{{#access}}<span class="access {{access}}">&lt;{{access}}></span> {{/access}}{{longname}}
<span class="summary">
{{#summary}}{{{summary}}}{{/summary}}
</span>
</h2>
<div>
<div class="details">
{{#description}}
<div class="description">
{{{description}}}
</div>
{{/description}}
{{#hasBorrowed}}
<h3>Mixes In:</h3>
<ol class="borrows detail-list">
{{#borrowed}} <li>{{#linkTo}}{{from}}{{/linkTo}}</li> {{/borrowed}}
</ol>
{{/hasBorrowed}}
{{#hasParams}}
<h3>Parameters:</h3>
{{>paramsTemplate}}
{{/hasParams}}
{{#hasReturns}}
<h3>Returns:</h3>
{{>returnsTemplate}}
{{/hasReturns}}
</div>
</div>
{{/docs}}
</body>
</html>

View File

@ -0,0 +1,65 @@
<dt id="<?js= longname ?>">
<h4 class="name"><?js= this.attribs + (kind == 'class'? 'new ':'') + name + this.signature ?></h4>
<?js if (this.summary) { ?>
<p class="summary"><?js= summary ?></p>
<?js } ?>
</dt>
<dd>
<?js if (this.description) { ?>
<h5>Description:</h5>
<p class="description">
<?js= this.description ?>
</p>
<?js } ?>
<?js
if (this.params && params.length) {
print('<h5>Parameters:</h5>');
print( render('params.tmpl', params) );
}
?>
<?js if (this.fires && fires.length) { ?>
<h5>Fires:</h5>
<ul><?js
fires.forEach(function(f) {
print( render('fires.tmpl', f) );
});
?></ul>
<?js } ?>
<?js if (this.exceptions && exceptions.length) { ?>
<h5>Throws:</h5>
<ul><?js
exceptions.forEach(function(e) {
print( render('exceptions.tmpl', e) );
});
?></ul>
<?js } ?>
<?js
if (this.returns && returns.length) {
var rdesc = [];
returns.forEach(function(r) {
if (r.description) rdesc.push(r.description);
});
if (rdesc.length) {
print('<h5>Returns:</h5>');
print('<p>'+rdesc.join('</p><p>')+'</p>');
}
}
?>
<?js
if (this.examples && examples.length) {
print('<h5>Example' + (examples.length > 1? 's':'') + '</h5>');
print( render('examples.tmpl', examples) );
}
?>
</dd>

View File

@ -1,33 +0,0 @@
<dt class="furtherDetailHeading" id="method:{{name}}">
<h4 class="method-title">{{name}}</h4>
</dt>
<dd>
{{#summary}}<p class="shortDesc">{{{summary}}}</p>{{/summary}}
<div class="apiFurtherDetail" style="height: auto;">
<h5>Synopsis:</h5>
<pre class="synopsis"><code>{{synopsis}}</code></pre>
{{#hasParams}}
<h5>Parameters:</h5>
{{>paramsTemplate}}
{{/hasParams}}
{{#hasExceptions}}
<h5>Throws:</h5>
{{>exceptionsTemplate}}
{{/hasExceptions}}
{{#hasReturns}}
<h5>Returns:</h5>
{{>returnsTemplate}}
{{/hasReturns}}
{{#hasExamples}}
{{>examplesTemplate}}
{{/hasExamples}}
</div>
</dd>

View File

@ -1,10 +0,0 @@
<dl class="namespaces">
{{#namespaces}}
<dt class="furtherDetailHeading">
<h4 class="namespace-title"><a href="namespaces.html#{{longname}}">{{name}}</a></h4>
</dt>
<dd>
{{#summary}}<p class="shortDesc">{{{summary}}}</p>{{/summary}}
</dd>
{{/namespaces}}
</dl>

View File

@ -1,53 +0,0 @@
<dl class="params detail-list">
{{#params}}
<dt{{#first?}} class="first"{{/first?}}>
<h6>{{name}}</h6>
</dt>
<dd>
<dl class="param-properties">
{{#type}}
<dt>
<span>Type</span>
</dt>
<dd>
{{#names}}
<span class="param-type">{{#linkTo}}{{.}}{{/linkTo}}</span>{{^last?}} | {{/last?}}{{#last?}} {{/last?}}
{{/names}}
</dd>
{{#defaultvalue}}
<dt>
<span>Default</span>
</dt>
<dd>
{{defaultvalue}}
</dd>
{{/defaultvalue}}
{{#optional}}
<dt>
<span>Optional</span>
</dt>
<dd class="yesDef">Yes</dd>
{{/optional}}
{{#nullable}}
<dt>
<span>Nullable</span>
</dt>
<dd class="yesDef">Yes</dd>
{{/nullable}}
{{/type}}
</dl>
{{#description}}
<div class="param-desc">
{{description}}
</div>
{{/description}}
</dd>
{{/params}}
</dl>

View File

@ -0,0 +1,115 @@
<?js
var params = this;
/* sort subparams under their parent params (like opts.classname) */
var parentParam = null;
params.forEach(function(param, i) {
if (!param) { return; }
if ( parentParam && param.name.indexOf(parentParam.name + '.') === 0 ) {
param.name = param.name.substr(parentParam.name.length+1);
parentParam.subparams = parentParam.subparams || [];
parentParam.subparams.push(param);
params[i] = null;
}
else {
parentParam = param;
}
});
/* determine if we need extra columns, "attributes" and "default" */
params.hasAttributes = false;
params.hasDefault = false;
params.hasName = false;
params.forEach(function(param) {
if (!param) { return; }
if (param.optional || param.nullable) {
params.hasAttributes = true;
}
if (param.name) {
params.hasName = true;
}
if (typeof param.defaultvalue !== 'undefined') {
params.hasDefault = true;
}
});
?>
<table class="params">
<thead>
<tr>
<?js if (params.hasName) {?>
<th>Name</th>
<?js } ?>
<th>Type</th>
<?js if (params.hasAttributes) {?>
<th>Argument</th>
<?js } ?>
<?js if (params.hasDefault) {?>
<th>Default</th>
<?js } ?>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<?js
params.forEach(function(param) {
if (!param) { return; }
?>
<tr>
<?js if (params.hasName) {?>
<td class="name"><code><?js= param.name ?></code></td>
<?js } ?>
<td class="type">
<?js
if (param.type && param.type.names) {
param.type.names.forEach(function(name, i) {
print( htmlsafe(name) );
if (i < param.type.names.length-1) { print(' | '); }
});
}
?>
</td>
<?js if (params.hasAttributes) {?>
<td class="attributes">
<?js
if (param.optional) {
print( '&lt;optional><br>' );
}
if (param.nullable) {
print( '&lt;nullable><br>' );
}
?>
</td>
<?js } ?>
<?js if (params.hasDefault) {?>
<td class="default">
<?js
if (typeof param.defaultvalue !== 'undefined') {
print( htmlsafe(param.defaultvalue) );
}
?>
</td>
<?js } ?>
<td class="description last"><?js= param.description ?><?js if (param.subparams) {
print( '<h6>Properties</h6>' + render('params.tmpl', param.subparams) );
}?></td>
</tr>
<?js }); ?>
</tbody>
</table>

View File

@ -1,88 +0,0 @@
<div class="property">
<dl class="property-head{{#deprecated}} property-deprecated{{/deprecated}}" id="{{longname}}">
<dt class="property-name">
{{name}}
</dt>
<dd class="property-summary">
{{{summary}}}
</dd>
</dl>
<dl class="property-details">
{{#description}}
<dt>
Description
</dt>
<dd>
{{{description}}}
<br clear="both">
</dd>
{{/description}}
{{#deprecated}}
<dt>
Deprecated
</dt>
<dd>
{{{deprecated}}}
<br clear="both">
</dd>
{{/deprecated}}
{{#since}}
<dt>
Since
</dt>
<dd>
{{{since}}}
<br clear="both">
</dd>
{{/since}}
{{#type}}
<dt>
Type
</dt>
<dd>
{{#names}}
<span class="type-name">{{#linkTo}}{{.}}{{/linkTo}}</span>{{^last?}} | {{/last?}}{{#last?}} {{/last?}}
{{/names}}
<br clear="both">
</dd>
{{/type}}
{{#readonly}}
<dt>
Readonly
</dt>
<dd class="yesDef">
Yes
<br clear="both">
</dd>
{{/readonly}}
{{#nullable}}
<dt>
Nullable
</dt>
<dd class="yesDef">
Yes
<br clear="both">
</dd>
{{/nullable}}
{{#defaultvalue}}
<dt>
Default
</dt>
<dd>
{{defaultvalue}}
<br clear="both">
</dd>
{{/defaultvalue}}
{{#hasExamples}}
{{>examplesTemplate}}
{{/hasExamples}
</dl>
</div>

View File

@ -0,0 +1,47 @@
<dt id="property:<?js= longname ?>">
<h4 class="name"><?js= this.attribs + name + this.signature ?></h4>
<?js if (this.summary) { ?>
<p class="summary"><?js= summary ?></p>
<?js } ?>
</dt>
<dd>
<?js if (this.description) { ?>
<h5>Description:</h5>
<p>
<?js= this.description ?>
</p>
<?js } ?>
<?js if (this.type || this.deprecated || this.since || this.readonly || typeof this.defaultvalue !== 'undefined') { ?>
<dl>
<?js if (this.deprecated) { ?>
<dt>Deprecated</dt>
<dd class="yesDef">Yes</dd>
<?js } ?>
<?js if (this.since) { ?>
<dt>Since</dt>
<dd><?js= this.since ?></dd>
<?js } ?>
<?js if (this.readonly) { ?>
<dt>Read-Only</dt>
<dd class="yesDef">Yes</dd>
<?js } ?>
<?js if (typeof this.defaultvalue !== 'undefined') { ?>
<dt>Default Value</dt>
<dd><?js= this.defaultvalue ?></dd>
<?js } ?>
</dl>
<?js } ?>
<?js
if (this.examples && examples.length) {
print('<h5>Example' + (examples.length > 1? 's':'') + '</h5>');
print( render('examples.tmpl', examples) );
}
?>
</dd>

View File

@ -1,28 +0,0 @@
<dl class="params detail-list">
{{#returns}}
<dt{{#first?}} class="first"{{/first?}}></dt>
<dd>
<dl class="param-properties">
{{#type}}
<dt>
<span>Type</span>
</dt>
<dd>
{{#names}}
<span class="param-type">{{#linkTo}}{{.}}{{/linkTo}}</span>{{^last?}} | {{/last?}}{{#last?}} {{/last?}}
{{/names}}
</dd>
{{/type}}
</dl>
{{#description}}
<div class="param-desc">
{{description}}
</div>
{{/description}}
</dd>
{{/returns}}
</dl>

View File

@ -0,0 +1,31 @@
<li>
<?js if (this.description) { ?>
<div class="param-desc">
<?js= description ?>
</div>
<?js } ?>
<?js
if (this.type) {
with(type) {
?>
<dl>
<dt>
Type
</dt>
<dd>
<?js
names.forEach(function(name, i) {
?>
<span class="param-type"><?js= htmlsafe(name) ?></span> <?js if (i < names.length-1) print('|'); ?>
<?js
});
?>
</dd>
</dl>
<?js
}
}
?>
</li>