mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Improved support for @alias when documenting inner classes as global.
This commit is contained in:
parent
1efee9d908
commit
810dd7f7fd
@ -24,7 +24,7 @@ exports.resolve = function(doclet) {
|
|||||||
about = {},
|
about = {},
|
||||||
parentDoc;
|
parentDoc;
|
||||||
|
|
||||||
doclet.name = name = name? (''+name).replace(/\.prototype\.?/g, '#') : '';
|
doclet.name = name = name? (''+name).replace(/(^|\.)prototype\.?/g, '#') : '';
|
||||||
|
|
||||||
// member of a var in an outer scope?
|
// member of a var in an outer scope?
|
||||||
if (name && !memberof && doclet.meta.code && doclet.meta.code.funcscope) {
|
if (name && !memberof && doclet.meta.code && doclet.meta.code.funcscope) {
|
||||||
@ -48,7 +48,7 @@ exports.resolve = function(doclet) {
|
|||||||
else { // no @memberof
|
else { // no @memberof
|
||||||
about = exports.shorten(name);
|
about = exports.shorten(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (about.name) {
|
if (about.name) {
|
||||||
doclet.name = about.name;
|
doclet.name = about.name;
|
||||||
}
|
}
|
||||||
@ -75,8 +75,12 @@ exports.resolve = function(doclet) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (doclet.name && doclet.memberof && !doclet.longname) {
|
if (doclet.name && doclet.memberof && !doclet.longname) {
|
||||||
doclet.scope = 'static'; // default scope when none is provided
|
if ( /^([#.~])/.test(doclet.name) ) {
|
||||||
|
doclet.scope = puncToScope[RegExp.$1];
|
||||||
|
doclet.name = doclet.name.substr(1);
|
||||||
|
}
|
||||||
|
else doclet.scope = 'static'; // default scope when none is provided
|
||||||
|
|
||||||
doclet.setLongname(doclet.memberof + scopeToPunc[doclet.scope] + doclet.name);
|
doclet.setLongname(doclet.memberof + scopeToPunc[doclet.scope] + doclet.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
18
test/fixtures/aliasglobal2.js
vendored
Normal file
18
test/fixtures/aliasglobal2.js
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
(function () {
|
||||||
|
/**
|
||||||
|
* Creates a new test object.
|
||||||
|
* @alias Test
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
var Test = function(testName) {
|
||||||
|
/** Document me. */
|
||||||
|
this.name = testName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Document me. */
|
||||||
|
Test.prototype.run = function(message) {
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Document me. */
|
||||||
|
Test.counter = 1;
|
||||||
|
})();
|
||||||
@ -40,6 +40,14 @@ describe("aliases", function() {
|
|||||||
|
|
||||||
expect(log.scope).toEqual('global');
|
expect(log.scope).toEqual('global');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('When a symbol is documented as an instance member of <global> class it\'s scope is "instance" and not "static".', function() {
|
||||||
|
var docSet = jasmine.getDocSetFromFile('test/fixtures/aliasglobal2.js'),
|
||||||
|
run = docSet.getByLongname('Test#run')[0];
|
||||||
|
|
||||||
|
expect(run.scope).toEqual('instance');
|
||||||
|
expect(run.memberof).toEqual('Test');
|
||||||
|
});
|
||||||
|
|
||||||
describe("resolving", function() {
|
describe("resolving", function() {
|
||||||
it('When a local reference has alias, put all members into aliased definition. Local modifications should be visible to outside.', function() {
|
it('When a local reference has alias, put all members into aliased definition. Local modifications should be visible to outside.', function() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user