mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Merge pull request #634 from rassilon/issue-631
Fix issue #631: Virtual comments inside modules
This commit is contained in:
commit
48fa2fd320
@ -111,7 +111,7 @@ exports.resolve = function(doclet) {
|
|||||||
doclet.setMemberof(about.memberof);
|
doclet.setMemberof(about.memberof);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (about.longname && !doclet.longname) {
|
if (about.longname && (!doclet.longname || doclet.longname === doclet.name)) {
|
||||||
doclet.setLongname(about.longname);
|
doclet.setLongname(about.longname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -33,6 +33,20 @@ function setCurrentModule(doclet) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setDefaultScopeMemberOf(doclet) {
|
||||||
|
// add @inner and @memberof tags unless the current module exports only this symbol
|
||||||
|
if (currentModule && currentModule !== doclet.name) {
|
||||||
|
// add @inner unless the current module exports only this symbol
|
||||||
|
if (!doclet.scope) {
|
||||||
|
doclet.addTag('inner');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!doclet.memberof && doclet.scope !== 'global') {
|
||||||
|
doclet.addTag('memberof', currentModule);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attach these event handlers to a particular instance of a parser.
|
* Attach these event handlers to a particular instance of a parser.
|
||||||
* @param parser
|
* @param parser
|
||||||
@ -48,6 +62,8 @@ exports.attachTo = function(parser) {
|
|||||||
return false; // only interested in virtual comments (with a @name) here
|
return false; // only interested in virtual comments (with a @name) here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setDefaultScopeMemberOf(newDoclet);
|
||||||
|
newDoclet.postProcess();
|
||||||
addDoclet.call(parser, newDoclet);
|
addDoclet.call(parser, newDoclet);
|
||||||
|
|
||||||
e.doclet = newDoclet;
|
e.doclet = newDoclet;
|
||||||
@ -149,17 +165,7 @@ exports.attachTo = function(parser) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// add @inner and @memberof tags unless the current module exports only this symbol
|
setDefaultScopeMemberOf(newDoclet);
|
||||||
if (currentModule && currentModule !== newDoclet.name) {
|
|
||||||
// add @inner unless the current module exports only this symbol
|
|
||||||
if (!newDoclet.scope) {
|
|
||||||
newDoclet.addTag('inner');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!newDoclet.memberof && newDoclet.scope !== 'global') {
|
|
||||||
newDoclet.addTag('memberof', currentModule);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
37
test/fixtures/moduletag4.js
vendored
Normal file
37
test/fixtures/moduletag4.js
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/** @module M1 */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The differnet kind of mouse buttons.
|
||||||
|
*
|
||||||
|
* @summary Blah blah
|
||||||
|
* @readonly
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
exports.MouseButtons = {
|
||||||
|
Left: "Left",
|
||||||
|
Middle: "Middle",
|
||||||
|
Right: "Right"
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef ClickProperties
|
||||||
|
* @type {object}
|
||||||
|
* @property {MouseButtons} Button - Which mouse button is clicking.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Virtual comment function
|
||||||
|
*
|
||||||
|
* @function VirtualComment
|
||||||
|
* @static
|
||||||
|
* @param {string} comment - comment
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Virtual comment function 2
|
||||||
|
* @function VirtualComment2
|
||||||
|
* @instance
|
||||||
|
* @param {string} comment - comment
|
||||||
|
*/
|
||||||
|
|
||||||
@ -38,4 +38,36 @@ describe("@module tag", function() {
|
|||||||
expect(darken.kind).toBe('function');
|
expect(darken.kind).toBe('function');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("virtual comments", function() {
|
||||||
|
var docSet = jasmine.getDocSetFromFile('test/fixtures/moduletag4.js'),
|
||||||
|
m1 = docSet.getByLongname('module:M1').filter(function($) {
|
||||||
|
return ! $.undocumented;
|
||||||
|
})[0],
|
||||||
|
clickProperties = docSet.getByLongname('module:M1~ClickProperties')[0],
|
||||||
|
virtFunc = docSet.getByLongname('module:M1.VirtualComment')[0],
|
||||||
|
virtFunc2 = docSet.getByLongname('module:M1#VirtualComment2')[0];
|
||||||
|
|
||||||
|
it('When a virtual comment typedef is inside a module, the typedef is a memberof the module', function () {
|
||||||
|
expect(clickProperties.memberof).toBe('module:M1');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('When a virtual comment typedef is inside a module, the typedef longname contains the module name', function() {
|
||||||
|
expect(clickProperties.longname).toBe('module:M1~ClickProperties');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('When a virtual comment typedef is inside a module, the typedef scope is "inner"', function() {
|
||||||
|
expect(clickProperties.scope).toBe('inner');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('When a virtual comment function is inside a module with a static scope, the function has the correct memberof and longname', function () {
|
||||||
|
expect(virtFunc.longname).toBe('module:M1.VirtualComment');
|
||||||
|
expect(virtFunc.memberof).toBe('module:M1');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('When a virtual comment function is inside a module with an instance scope, the function has the correct memberof and longname', function() {
|
||||||
|
expect(virtFunc2.longname).toBe('module:M1#VirtualComment2');
|
||||||
|
expect(virtFunc2.memberof).toBe('module:M1');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user