Changes to update the haruki template to work with refactored core code.

This commit is contained in:
Michael Mathews 2011-01-09 14:05:39 +00:00
parent 06f81aaf6b
commit 2f60a28619
9 changed files with 316 additions and 175 deletions

View File

@ -1,14 +1,14 @@
License
=======
JSDoc 3 is free software. You may use it for commercial or any other purpose.
Unless otherwise noted below, JSDoc 3 is:
JSDoc 3 is free software, licensed under the Apache License,
Version 2.0 (the "License"); you MAY NOT use this software except in
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>
Licensed under the Apache License, Version 2.0 (the "License"); you
MAY NOT use this software except in compliance with the License.
All rights reserved.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@ -19,7 +19,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied. See the License for the specific language governing
permissions and limitations under the License.
You can obtain the source code for JSDoc 3 at
You may obtain the source code for JSDoc 3 at
https://github.com/micmath/JSDoc
@ -39,7 +39,7 @@ later/GPL 2.0 or later licenses.
https://developer.mozilla.org/en/Rhino_License
You can obtain the source code for Rhino from the Mozilla web site at
You may obtain the source code for Rhino from the Mozilla web site at
http://www.mozilla.org/rhino/download.html
json2xml (modules/goessner/json2xml)
@ -50,7 +50,7 @@ Copyright (c) Stefan Goessner 2006
json2xml is licensed under Creative Commons GNU LGPL License,
http://creativecommons.org/licenses/LGPL/2.1/
You can obtain the source code for json2xml at
You may obtain the source code for json2xml at
http://goessner.net/download/prj/jsonxml/
Node (modules/common/assert, modules/common/util)
@ -75,7 +75,7 @@ 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.
You can obtain the source code for Node at
You may obtain the source code for Node at
https://github.com/ry/node
JSONSchema Validator (modules/sitepen/jsonschema)
@ -83,20 +83,60 @@ JSONSchema Validator (modules/sitepen/jsonschema)
Copyright (c) 2007 Kris Zyp SitePen (www.sitepen.com)
Licensed under the MIT license.
Licensed under the MIT license. You may obtain a copy of the
License at http://www.opensource.org/licenses/mit-license.php
You can obtain the source code for JSONSchema Validator at
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.
You may obtain the source code for JSONSchema Validator at
http://github.com/kriszyp/commonjs-utils/blob/master/lib/json-schema.js
http://www.sitepen.com/blog/2010/03/02/commonjs-utilities/
markdown-js (modules/evilstreak/markdown)
----
markdown-js is released under the MIT license.
http://www.opensource.org/licenses/mit-license.php
markdown-js is released under the MIT license. You may obtain a copy of the
License at http://www.opensource.org/licenses/mit-license.php
You can obtain the source code for markdown-js at
http://github.com/evilstreak/markdown-js
Copyright (c) 2009-2010 Dominic Baggott
Copyright (c) 2009-2010 Ash Berlin
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.
You may obtain the source code for markdown-js at
https://github.com/evilstreak/markdown-js
sqlitejdbc (build/java/classes/sqlitejdbc-v054.jar)
----
@ -115,7 +155,7 @@ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
You can obtain the source code for sqlitejdbc at
You may obtain the source code for sqlitejdbc at
https://github.com/crawshaw/sqlitejdbc
MustacheJS (templates/lib/janl/mustache.js)
@ -143,5 +183,34 @@ 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.
You can obtain the source code for MustacheJS at
https://github.com/janl/mustache.js
You may obtain the source code for MustacheJS at
https://github.com/janl/mustache.js
TaffyDB (modules/typicaljoe/taffy.js)
----
Copyright (c) 2008 All rights reserved.
Software License Agreement (BSD License)
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the
following condition is met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
You may obtain the source code for TaffyDB at
https://github.com/typicaljoe/taffydb

View File

@ -31,7 +31,7 @@ function require(id) { // like commonjs
f.call({}, require, exports, module);
if (module.exports) { exports = module.exports; }
exports = module.exports || exports;
require.cache[id] = exports;
}
catch(e) {
@ -161,7 +161,6 @@ function main() {
exit(0);
}
env.opts.template = env.opts.template || 'default';
// should define a global "publish" function
@ -173,5 +172,6 @@ function main() {
{ destination: env.opts.destination }
);
}
// TODO throw no publish warning?
}
}

View File

@ -86,6 +86,11 @@
this.borrowed.push( {from: source, as: (target||'this')} );
}
exports.Doclet.prototype.augment = function(base) {
if (!this.augments) { this.augments = []; }
this.augments.push(base);
}
function applyTag(tag) {
if (tag.title === 'name') {
this.name = tag.value;

View File

@ -1,5 +1,8 @@
/** @module jsdoc/docset */
// TODO: this module is currently only ever used as a helper in the test runner
// Can it be refactored a=out of the source code?
(function() {
var DocSet = exports.DocSet = function(doclets) {
this.doclets = doclets;

View File

@ -55,7 +55,7 @@
if (tagName) { this.value.name = tagName; }
if (tagDesc) { this.value.description = tagDesc; }
if (tagOptional) { this.value.optional = tagOptional; }
if (tagDefault) { this.value.defaultValue = tagDefault; }
if (tagDefault) { this.value.defaultvalue = tagDefault; }
}
else {
this.value.description = remainingText;

View File

@ -19,9 +19,22 @@
.synonym('extends')
.synonym('mixes');
dictionary.defineTag('augments', {
mustHaveValue: true,
onTagged: function(doclet, tag) {
doclet.augment(tag.value);
return false;
}
})
.synonym('extends');
dictionary.defineTag('class', {
onTagged: function(doclet, tag) { // @class implies @constructor
doclet.addTag('kind', 'constructor');
doclet.classdesc = tag.value;
return false;
}
});
@ -200,6 +213,24 @@
.synonym('field')
.synonym('var');
dictionary.defineTag('protected', {
mustNotHaveValue: true,
onTagged: function(doclet, tag) {
doclet.access = 'protected';
return true;
}
});
dictionary.defineTag('public', {
mustNotHaveValue: true,
onTagged: function(doclet, tag) {
doclet.access = 'public';
return true;
}
});
dictionary.defineTag('returns', {
mustHaveValue: true,
canHaveType: true,
@ -211,9 +242,9 @@
})
.synonym('return');
dictionary.defineTag('static', {
});
// dictionary.defineTag('static', {
//
// });
dictionary.defineTag('undocumented', {
mustNotHaveValue: true,

View File

@ -3,10 +3,11 @@
include('templates/lib/janl/mustache.js');
/**
@param {TAFFY} db
@global
@param {TAFFY} data
@param {object} opts
*/
publish = function(db, opts) {
publish = function(data, opts) {
var out = '',
templateSource = {
index: readFile(BASEDIR + 'templates/default/tmpl/index.mustache'),
@ -20,7 +21,7 @@
var linkTo,
text = render(text);
if ( !db.find({longname: text}).length ) { return text; }
if ( !data.find({longname: text}).length ) { return text; }
linkTo = text.replace(/#/g, '%23');
return '<a href="#' + linkTo + '">' + text + '</a>';
@ -46,17 +47,17 @@
return text.replace(/^\s+|\s+$/g, '');
}
db.remove({undocumented: true});
data.remove({undocumented: true});
// add template helpers
db.forEach(function(doclet) {
data.forEach(function(doclet) {
doclet.hasParams = doclet.params && doclet.params.length > 0;
doclet.hasBorrowed = doclet.borrowed && doclet.borrowed.length > 0;
summarize(doclet);
});
db.orderBy(['longname', 'kind']);
data.orderBy(['longname', 'kind']);
var partials = {
param: templateSource.param,
@ -67,7 +68,7 @@
out = Mustache.to_html(
templateSource.index,
{
docs: db.get(),
docs: data.get(),
linkTo: helpers.linkTo
},
partials

View File

@ -1,156 +1,174 @@
/**
@overview Builds a tree-like JSON string from the doclet data.
@version 0.0.1
*/
(function() {
var dumper = require('flesler/jsdump');
publish = function(docs, opts) { // global
/**
@global
@param {TAFFY} data
@param {object} opts
*/
publish = function(data, opts) {
var rootNamespace = {},
docs;
data.remove({undocumented: true});
docs = data.get(); // <-- an array of Doclet objects
function addDocNode(to, from, parentPath, parentName) {
from.filter(function (element) {
return (element.memberof === parentPath);
}).forEach(function (element) {
if (element.kind === 'namespace') {
if (! to.namespaces) {
to.namespaces = {};
}
var thisNamespace = to.namespaces[element.name] = {
'name': element.name,
'description': element.desc || '',
'access': element.access || ''
};
addDocNode(thisNamespace, from, element.path, element.name);
graft(rootNamespace, docs);
dump(rootNamespace);
}
function graft(parentNode, childNodes, parentLongname, parentName) {
childNodes
.filter(function (element) {
return (element.memberof === parentLongname);
})
.forEach(function (element, i) {
//print((i+1)+': '+element.kind+' '+element.longname+' ('+element.name+')');
if (element.kind === 'namespace') {
if (! parentNode.namespaces) {
parentNode.namespaces = { };
}
else if (element.kind === 'mixin') {
if (! to.mixins) {
to.mixins = {};
}
var thisMixin = to.mixins[element.name] = {
'name': element.name,
'description': element.desc || '',
'access': element.access || ''
};
addDocNode(thisMixin, from, element.path, element.name);
var thisNamespace = parentNode.namespaces[element.name] = {
'name': element.name,
'description': element.description || '',
'access': element.access || ''
};
graft(thisNamespace, childNodes, element.longname, element.name);
}
else if (element.kind === 'mixin') {
if (! parentNode.mixins) {
parentNode.mixins = { };
}
else if (element.kind === 'method') {
var _to = to;
// if (element.scope === 'static') {
// if (to.constructor) { // like a class
// to = to.constructor;
// }
// }
if (! to.functions) {
to.functions = {};
var thisMixin = parentNode.mixins[element.name] = {
'name': element.name,
'description': element.description || '',
'access': element.access || ''
};
graft(thisMixin, childNodes, element.longname, element.name);
}
else if (element.kind === 'function') {
if (! parentNode.functions) {
parentNode.functions = { };
}
var thisFunction = parentNode.functions[element.name] = {
'name': element.name,
'access': element.access || '',
'description': element.description || '',
'parameters': [ ]
};
if (element.returns) {
parentNode.functions[element.name].returns = {
'type': element.returns.type? (element.returns.type.names.length === 1? element.returns.type.names[0] : element.returns.type.names) : '',
'description': element.returns.description || ''
};
}
if (element.params) {
for (var i = 0, len = element.params.length; i < len; i++) {
thisFunction.parameters.push({
'name': element.params[i].name,
'type': element.params[i].type? (element.params[i].type.names.length === 1? element.params[i].type.names[0] : element.params[i].type.names) : '',
'description': element.params[i].description || '',
'default': element.params[i].defaultvalue || '',
'optional': typeof element.params[i].optional === 'boolean'? element.params[i].optional : '',
'nullable': typeof element.params[i].nullable === 'boolean'? element.params[i].nullable : ''
});
}
var thisFunction = to.functions[element.name] = {
}
}
else if (element.kind === 'property') {
if (! parentNode.properties) {
parentNode.properties = { };
}
parentNode.properties[element.name] = {
'name': element.name,
'access': element.access || '',
'description': element.description || '',
'type': element.type? (element.type.length === 1? element.type[0] : element.type) : ''
};
}
else if (element.kind === 'event') {
if (! parentNode.events) {
parentNode.events = { };
}
var thisEvent = parentNode.events[element.name] = {
'name': element.name,
'access': element.access || '',
'description': element.description || '',
'parameters': [
]
};
if (element.returns) {
parentNode.events[element.name].returns = {
'type': element.returns.type? (element.returns.type.names.length === 1? element.returns.type.names[0] : element.returns.type.names) : '',
'description': element.returns.description || ''
};
}
if (element.params) {
for (var i = 0, len = element.params.length; i < len; i++) {
thisEvent.parameters.push({
'name': element.params[i].name,
'type': element.params[i].type? (element.params[i].type.names.length === 1? element.params[i].type.names[0] : element.params[i].type.names) : '',
'description': element.params[i].description || '',
'default': element.params[i].defaultvalue || '',
'optional': typeof element.params[i].optional === 'boolean'? element.params[i].optional : '',
'nullable': typeof element.params[i].nullable === 'boolean'? element.params[i].nullable : ''
});
}
}
}
else if (element.kind === 'constructor') {
if (! parentNode.classes) {
parentNode.classes = { };
}
var thisClass = parentNode.classes[element.name] = {
'name': element.name,
'description': element.classdesc || '',
'extends': element.augments || [],
'access': element.access || '',
'fires': element.fires || '',
'constructor': {
'name': element.name,
'access': element.access || '',
'description': element.desc || '',
'description': element.description || '',
'parameters': [
]
};
if (element.returns !== undefined) {
to.functions[element.name].returns = element.returns;
}
if (element.param) for (var i = 0, len = element.param.length; i < len; i++) {
thisFunction.parameters.push({
'name': element.param[i].name,
'type': element.param[i].type? (element.param[i].type.length === 1? element.param[i].type[0] : element.param[i].type) : '',
'description': element.param[i].desc || '',
'default': element.param[i].defaultvalue || '',
'optional': typeof element.param[i].optional === 'boolean'? element.param[i].optional : '',
'nullable': typeof element.param[i].nullable === 'boolean'? element.param[i].nullable : ''
});
};
if (element.params) {
for (var i = 0, len = element.params.length; i < len; i++) {
thisClass.constructor.parameters.push({
'name': element.params[i].name,
'type': element.params[i].type? (element.params[i].type.names.length === 1? element.params[i].type.names[0] : element.params[i].type.names) : '',
'description': element.params[i].description || '',
'default': element.params[i].defaultvalue || '',
'optional': typeof element.params[i].optional === 'boolean'? element.params[i].optional : '',
'nullable': typeof element.params[i].nullable === 'boolean'? element.params[i].nullable : ''
});
}
to = _to;
}
else if (element.kind === 'property') {
var _to = to;
if (element.scope === 'static') {
if (to.constructor) { // like a class
to = to.constructor;
}
}
if (! to.properties) {
to.properties = {};
}
to.properties[element.name] = {
'name': element.name,
'access': element.access || '',
'description': element.desc || '',
'type': element.type? (element.type.length === 1? element.type[0] : element.type) : ''
};
to = _to;
}
else if (element.kind === 'event') {
var _to = to;
if (! to.events) {
to.events = {};
}
var thisEvent = to.events[element.name] = {
'name': element.name,
'access': element.access || '',
'description': element.desc || '',
'parameters': [
]
};
if (element.returns !== undefined) {
to.events[element.name].returns = element.returns;
}
if (element.param) for (var i = 0, len = element.param.length; i < len; i++) {
thisEvent.parameters.push({
'name': element.param[i].name,
'type': element.param[i].type? (element.param[i].type.length === 1? element.param[i].type[0] : element.param[i].type) : '',
'description': element.param[i].desc || '',
'default': element.param[i].defaultvalue || '',
'optional': typeof element.param[i].optional === 'boolean'? element.param[i].optional : '',
'nullable': typeof element.param[i].nullable === 'boolean'? element.param[i].nullable : ''
});
}
to = _to;
}
else if (element.kind === 'constructor') {
if (! to.classes) {
to.classes = {};
}
var thisClass = to.classes[element.name] = {
'name': element.name,
'description': element.classdesc || '',
'extends': element.augments || [],
'access': element.access || '',
'fires': element.fires || '',
'constructor': {
'name': element.name,
'description': element.desc || '',
'parameters': [
]
}
};
if (element.param) for (var i = 0, len = element.param.length; i < len; i++) {
thisClass.constructor.parameters.push({
'name': element.param[i].name,
'type': element.param[i].type? (element.param[i].type.length === 1? element.param[i].type[0] : element.param[i].type) : '',
'description': element.param[i].desc || '',
'default': element.param[i].defaultvalue || '',
'optional': typeof element.param[i].optional === 'boolean'? element.param[i].optional : '',
'nullable': typeof element.param[i].nullable === 'boolean'? element.param[i].nullable : ''
});
}
addDocNode(thisClass, from, element.path, element.name);
}
});
}
var rootNamespace = {};
addDocNode(rootNamespace, docs.doc, undefined);
print(dumper.jsDump.parse(rootNamespace));
}
graft(thisClass, childNodes, element.longname, element.name);
}
});
}
})();

View File

@ -17,14 +17,23 @@
var errors = [];
/**
Overall namespace object for this library.
@public
@namespace geometry
*/
geometry = {};
/**
Handy utility functions related to geometry.
@namespace geometry.util
*/
geometry.util = {};
geometry.util = {
/** Determine if 2 shapes intersect.
@returns {boolean} True if they do intersect.
*/
intersects: function(shape1, shape2) {
}
};
/**
* @class This class exists to demonstrate the assignment of a class prototype
@ -50,6 +59,7 @@ geometry.util.ShapeFactory.prototype = {
* @class This is the basic Shape class.
* It can be considered an abstract class, even though no such thing
* really existing in JavaScript
* @borrows threeD
* @param {Object} template
* @throws {MemoryException} If there is no more memory
* @throws GeneralShapeException rarely (if ever)
@ -510,7 +520,11 @@ function _getArea() {
}
// see http://www.integralist.co.uk/javascript/implementing-interfaces-in-javascript/
/** @var */
/**
Adds functionality related to three-dimensional calculations.
@protected
@mixin
*/
var threeD = new Interface('threeD');
/**