mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Added support for @global tag.
This commit is contained in:
parent
080ac73d49
commit
fc5319020f
5
main.js
5
main.js
@ -1,9 +1,10 @@
|
|||||||
/**
|
/**
|
||||||
* @overview JSDoc/main.js
|
* @project JSDoc
|
||||||
* @copyright 2010, 2011 (c) Michael Mathews <micmath@gmail.com>
|
* @author Michael Mathews <micmath@gmail.com>
|
||||||
* @license See LICENSE.md file included in this distribution.
|
* @license See LICENSE.md file included in this distribution.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,7 @@
|
|||||||
@param {Doclet} doclet
|
@param {Doclet} doclet
|
||||||
*/
|
*/
|
||||||
exports.resolve = function(doclet) {
|
exports.resolve = function(doclet) {
|
||||||
|
|
||||||
var name = doclet.name,
|
var name = doclet.name,
|
||||||
memberof = doclet.memberof || '',
|
memberof = doclet.memberof || '',
|
||||||
about = {},
|
about = {},
|
||||||
@ -65,7 +66,11 @@
|
|||||||
doclet.longname = about.longname;
|
doclet.longname = about.longname;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (about.scope) {
|
if (doclet.scope === 'global') { // via @global tag?
|
||||||
|
doclet.longname = doclet.name;
|
||||||
|
delete doclet.memberof;
|
||||||
|
}
|
||||||
|
else if (about.scope) {
|
||||||
doclet.scope = puncToScope[about.scope];
|
doclet.scope = puncToScope[about.scope];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -74,6 +79,8 @@
|
|||||||
doclet.longname = doclet.memberof + scopeToPunc[doclet.scope] + doclet.name;
|
doclet.longname = doclet.memberof + scopeToPunc[doclet.scope] + doclet.name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function quoteUnsafe(name, kind) { // docspaced names may have unsafe characters which need to be quoted by us
|
function quoteUnsafe(name, kind) { // docspaced names may have unsafe characters which need to be quoted by us
|
||||||
|
|||||||
@ -108,6 +108,15 @@
|
|||||||
})
|
})
|
||||||
.synonym('method');
|
.synonym('method');
|
||||||
|
|
||||||
|
dictionary.defineTag('global', {
|
||||||
|
mustNotHaveValue: true,
|
||||||
|
onTagged: function(doclet, tag) {
|
||||||
|
doclet.scope = 'global';
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
dictionary.defineTag('inner', {
|
dictionary.defineTag('inner', {
|
||||||
onTagged: function(doclet, tag) {
|
onTagged: function(doclet, tag) {
|
||||||
setDocletScopeToTitle(doclet, tag);
|
setDocletScopeToTitle(doclet, tag);
|
||||||
|
|||||||
16
test/cases/globaltag.js
Normal file
16
test/cases/globaltag.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/**
|
||||||
|
@global
|
||||||
|
@constructor
|
||||||
|
*/
|
||||||
|
window.Bar = new Function('', a, b, c);
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
|
||||||
|
/** @global */
|
||||||
|
var foo;
|
||||||
|
|
||||||
|
foo = 'hello foo';
|
||||||
|
|
||||||
|
this.foo = foo;
|
||||||
|
|
||||||
|
}).apply(window);
|
||||||
@ -89,5 +89,7 @@ testFile('test/t/cases/modules/data/mod-2.js');
|
|||||||
testFile('test/t/cases/alias.js');
|
testFile('test/t/cases/alias.js');
|
||||||
testFile('test/t/cases/alias2.js');
|
testFile('test/t/cases/alias2.js');
|
||||||
|
|
||||||
|
testFile('test/t/cases/globaltag.js');
|
||||||
|
|
||||||
report();
|
report();
|
||||||
|
|
||||||
|
|||||||
28
test/t/cases/globaltag.js
Normal file
28
test/t/cases/globaltag.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
(function() {
|
||||||
|
var docSet = testhelpers.getDocSetFromFile('test/cases/globaltag.js'),
|
||||||
|
found = docSet.getByLongname('foo').filter(function($) {
|
||||||
|
return ! $.undocumented;
|
||||||
|
});
|
||||||
|
|
||||||
|
//dump(docSet.doclets);
|
||||||
|
|
||||||
|
test('When an inner symbol has a @global tag it is documented as if it were global.', function() {
|
||||||
|
assert.equal(found[0].name, 'foo');
|
||||||
|
assert.equal(found[0].longname, 'foo');
|
||||||
|
assert.equal(found[0].memberof, undefined);
|
||||||
|
assert.equal(found[0].scope, 'global');
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
found = docSet.getByLongname('Bar').filter(function($) {
|
||||||
|
return ! $.undocumented;
|
||||||
|
});
|
||||||
|
|
||||||
|
test('When an nested symbol has a @global tag it is documented as if it were global.', function() {
|
||||||
|
assert.equal(found[0].name, 'Bar');
|
||||||
|
assert.equal(found[0].longname, 'Bar');
|
||||||
|
assert.equal(found[0].memberof, undefined);
|
||||||
|
assert.equal(found[0].scope, 'global');
|
||||||
|
});
|
||||||
|
|
||||||
|
})();
|
||||||
Loading…
x
Reference in New Issue
Block a user