Skip to content

Commit

Permalink
Added support for @Lends to the global.
Browse files Browse the repository at this point in the history
  • Loading branch information
micmath committed Apr 9, 2011
1 parent d7675bb commit 20416aa
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 4 deletions.
8 changes: 7 additions & 1 deletion modules/jsdoc/doclet.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
if (this.name && !this.longname) {
this.setLongname(this.name);
}
if (this.memberof === '') {
delete(this.memberof);
}
if (!this.kind && this.meta && this.meta.code) {
this.addTag( 'kind', codetypeToKind(this.meta.code.type) );
}
Expand All @@ -62,7 +65,7 @@
exports.Doclet.prototype.addTag = function(title, text) {
var tagDef = jsdoc.tag.dictionary.lookUp(title),
newTag = new jsdoc.tag.Tag(title, text, this.meta);

if (tagDef && tagDef.onTagged) {
tagDef.onTagged(this, newTag)
}
Expand All @@ -79,6 +82,7 @@
@param {string} sid - The longname of the symbol that this doclet is a member of.
*/
exports.Doclet.prototype.setMemberof = function(sid) {
if (/^<global>\.?/.test(sid)) { sid = sid.replace(/^<global>.?/, ''); }
/**
The longname of the symbol that contains this one, if any.
@type string
Expand All @@ -90,6 +94,8 @@
@param {string} name
*/
exports.Doclet.prototype.setLongname = function(name) {
if (/^<global>\.?/.test(name)) { name = name.replace(/^<global>\.?/, ''); }

/**
The fully resolved symbol name.
@type string
Expand Down
4 changes: 2 additions & 2 deletions modules/jsdoc/tag/dictionary/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
});

dictionary.defineTag('lends', {
mustHaveValue: true,
// mustHaveValue: true,
onTagged: function(doclet, tag) {
doclet.alias = tag.value;
doclet.alias = tag.value || '<global>';
doclet.addTag('undocumented');
}
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jsdoc",
"version": "3.0.0beta1",
"revision": "2011-03-29-2211",
"revision": "2011-04-09-2143",
"description": "An automatic documentation generator for javascript.",
"keywords": [ "documentation", "javascript" ],
"licenses": [
Expand Down
14 changes: 14 additions & 0 deletions test/cases/lendsglobal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
declare({
globals: /** @lends */ {

/** document me */
'test': function() { },

/** @namespace */
'test1': {

/** document me */
'test2': function() { }
}
}
});
1 change: 1 addition & 0 deletions test/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ testFile('test/t/cases/globaltag.js');
testFile('test/t/cases/ignoretag.js');
testFile('test/t/cases/lends.js');
testFile('test/t/cases/lends2.js');
testFile('test/t/cases/lendsglobal.js');
testFile('test/t/cases/memberoftag.js');
testFile('test/t/cases/memberoftag2.js');
testFile('test/t/cases/moduletag.js');
Expand Down
17 changes: 17 additions & 0 deletions test/t/cases/lendsglobal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
(function() {
var docSet = testhelpers.getDocSetFromFile('test/cases/lendsglobal.js'),
testf = docSet.getByLongname('test')[0],
test1 = docSet.getByLongname('test1')[0],
test12 = docSet.getByLongname('test1.test2')[0];

//dump(testf, test1, test12); exit();

test('When a documented member is inside an objlit associated with a @lends tag that has no value.', function() {
assert.equal(typeof testf.memberof, 'undefined', 'The members of the objlit are not members of any symbol.');
assert.equal(testf.longname, 'test', 'The members of the objlit are documented as global.');


assert.equal(test12.memberof, 'test1', 'The nested members of the objlit are members of a global symbol.');
});

})();

0 comments on commit 20416aa

Please sign in to comment.