Merge branch 'master' of github.com:micmath/jsdoc

This commit is contained in:
Michael Mathews 2011-12-11 10:46:51 +00:00
commit ce7338d8c9
9 changed files with 81 additions and 7 deletions

View File

@ -155,8 +155,18 @@ function main() {
throw('Configuration file cannot be evaluated. '+e);
}
// allow to pass arguments from configuration file
if (env.conf.opts) {
for (var opt in env.conf.opts) {
// arguments passed in command are more important
if (!(opt in env.opts)) {
env.opts[opt] = env.conf.opts[opt];
}
}
}
if (env.opts.query) {
env.opts.query = require('query').toObject(env.opts.query);
env.opts.query = require('common/query').toObject(env.opts.query);
}
// which version of javascript will be supported? (rhino only)
@ -230,10 +240,10 @@ function main() {
exit(0);
}
env.opts.template = env.opts.template || 'default';
env.opts.template = env.opts.template || 'templates/default';
// should define a global "publish" function
include('templates/' + env.opts.template + '/publish.js');
include(env.opts.template + '/publish.js');
if (typeof publish === 'function') {
publish(

View File

@ -12,7 +12,7 @@ var common = {
var argParser = new common.args.ArgParser(),
ourOptions,
defaults = {
template: 'default',
template: 'templates/default',
destination: './out/'
};

View File

@ -113,6 +113,11 @@ exports.jsdocSchema = {
"maxItems": 1,
"enum": ["private", "protected", "public"]
},
"virtual": { // is a member left to be implemented during inheritance?
"type": "boolean",
"optional": true,
"default": false
},
"attrib": { // other attributes, like "readonly"
"type": "string",
"optional": true

View File

@ -11,6 +11,15 @@
*/
exports.defineTags = function(dictionary) {
dictionary.defineTag('abstract', {
mustNotHaveValue: true,
onTagged: function(doclet, tag) {
// since "abstract" is reserved word in JavaScript let's use "virtual" in code
doclet.virtual = true;
}
})
.synonym('virtual');
dictionary.defineTag('access', {
mustHaveValue: true,
onTagged: function(doclet, tag) {

View File

@ -108,6 +108,10 @@
function addAttribs(f) {
var attribs = [];
if (f.virtual) {
attribs.push('virtual');
}
if (f.access && f.access !== 'public') {
attribs.push(f.access);
}

View File

@ -51,7 +51,8 @@
var thisNamespace = parentNode.namespaces[element.name] = {
'name': element.name,
'description': element.description || '',
'access': element.access || ''
'access': element.access || '',
'virtual': !!element.virtual
};
graft(thisNamespace, childNodes, element.longname, element.name);
@ -64,7 +65,8 @@
var thisMixin = parentNode.mixins[element.name] = {
'name': element.name,
'description': element.description || '',
'access': element.access || ''
'access': element.access || '',
'virtual': !!element.virtual
};
graft(thisMixin, childNodes, element.longname, element.name);
@ -77,6 +79,7 @@
var thisFunction = parentNode.functions[element.name] = {
'name': element.name,
'access': element.access || '',
'virtual': !!element.virtual,
'description': element.description || '',
'parameters': [ ]
};
@ -108,6 +111,7 @@
parentNode.properties[element.name] = {
'name': element.name,
'access': element.access || '',
'virtual': !!element.virtual,
'description': element.description || '',
'type': element.type? (element.type.length === 1? element.type[0] : element.type) : ''
};
@ -121,6 +125,7 @@
var thisEvent = parentNode.events[element.name] = {
'name': element.name,
'access': element.access || '',
'virtual': !!element.virtual,
'description': element.description || '',
'parameters': [
]
@ -156,6 +161,7 @@
'description': element.classdesc || '',
'extends': element.augments || [],
'access': element.access || '',
'virtual': !!element.virtual,
'fires': element.fires || '',
'constructor': {
'name': element.name,

17
test/cases/abstracttag.js Normal file
View File

@ -0,0 +1,17 @@
/** @constructor */
function Thingy() {
/** @abstract */
this.pez = 2;
}
// same as...
/** @constructor */
function OtherThingy() {
/** @virtual */
this.pez = 2;
}

View File

@ -103,6 +103,7 @@ testFile('test/t/cases/innerscope2.js');
testFile('test/t/cases/modules/data/mod-1.js');
testFile('test/t/cases/modules/data/mod-2.js');
testFile('test/t/cases/abstracttag.js');
testFile('test/t/cases/accesstag.js');
testFile('test/t/cases/alias.js');
testFile('test/t/cases/alias2.js');

View File

@ -0,0 +1,22 @@
(function() {
var docSet = testhelpers.getDocSetFromFile('test/cases/abstracttag.js'),
type = docSet.getByLongname('Thingy')[0]
pez = docSet.getByLongname('Thingy#pez')[0];
test('By default symbol has virtual=undefined property.', function() {
assert.equal(!!type.virtual, false);
});
test('When a symbol has a @abstract tag, the doclet has a virtual=true property.', function() {
assert.equal(pez.virtual, true);
});
// same as...
pez = docSet.getByLongname('OtherThingy#pez')[0];
test('When a symbol has a @virtual tag, the doclet has a virtual=true property.', function() {
assert.equal(pez.virtual, true);
});
})();