Skip to content

Commit

Permalink
Merge branch 'master' of github.com:micmath/jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
micmath committed Dec 11, 2011
2 parents 064dec2 + 6215791 commit ce7338d
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 7 deletions.
18 changes: 14 additions & 4 deletions jsdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand All @@ -244,4 +254,4 @@ function main() {
else { // TODO throw no publish warning?
}
}
}
}
2 changes: 1 addition & 1 deletion rhino_modules/jsdoc/opts/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var common = {
var argParser = new common.args.ArgParser(),
ourOptions,
defaults = {
template: 'default',
template: 'templates/default',
destination: './out/'
};

Expand Down
5 changes: 5 additions & 0 deletions rhino_modules/jsdoc/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions rhino_modules/jsdoc/tag/dictionary/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions templates/default/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
10 changes: 8 additions & 2 deletions templates/haruki/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -77,6 +79,7 @@
var thisFunction = parentNode.functions[element.name] = {
'name': element.name,
'access': element.access || '',
'virtual': !!element.virtual,
'description': element.description || '',
'parameters': [ ]
};
Expand Down Expand Up @@ -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) : ''
};
Expand All @@ -121,6 +125,7 @@
var thisEvent = parentNode.events[element.name] = {
'name': element.name,
'access': element.access || '',
'virtual': !!element.virtual,
'description': element.description || '',
'parameters': [
]
Expand Down Expand Up @@ -156,6 +161,7 @@
'description': element.classdesc || '',
'extends': element.augments || [],
'access': element.access || '',
'virtual': !!element.virtual,
'fires': element.fires || '',
'constructor': {
'name': element.name,
Expand Down
17 changes: 17 additions & 0 deletions test/cases/abstracttag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/** @constructor */
function Thingy() {

/** @abstract */
this.pez = 2;

}

// same as...

/** @constructor */
function OtherThingy() {

/** @virtual */
this.pez = 2;

}
1 change: 1 addition & 0 deletions test/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
22 changes: 22 additions & 0 deletions test/t/cases/abstracttag.js
Original file line number Diff line number Diff line change
@@ -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);
});

})();

0 comments on commit ce7338d

Please sign in to comment.