mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Fix for issue that caused scope to be wrong when @memberof was provided but no @name was given.
This commit is contained in:
parent
a84b8bcb19
commit
f2b689f09b
@ -48,7 +48,6 @@
|
||||
doclet.meta = meta;
|
||||
|
||||
postprocess(doclet);
|
||||
|
||||
name.resolve(doclet);
|
||||
|
||||
return doclet
|
||||
|
||||
@ -18,7 +18,8 @@
|
||||
currentModule = moduleName;
|
||||
}
|
||||
|
||||
var scopeModes = { '.':'static', '~':'inner', '#':'instance' };
|
||||
var puncToScope = { '.':'static', '~':'inner', '#':'instance' },
|
||||
scopeToPunc = { 'static':'.', 'inner':'~', 'instance':'#' };
|
||||
/**
|
||||
Calculates the path, memberof and name values.
|
||||
@method resolve
|
||||
@ -40,8 +41,8 @@
|
||||
name = name.replace(/^exports\.(?=.+$)/, currentModule + '.');
|
||||
}
|
||||
|
||||
path = name = name.replace(/\.prototype\.?/g, '#');
|
||||
|
||||
path = name = name? (''+name).replace(/\.prototype\.?/g, '#') : '';
|
||||
|
||||
if (memberof) { // @memberof tag given
|
||||
// like @name foo.bar, @memberof foo
|
||||
if (name.indexOf(memberof) === 0) {
|
||||
@ -51,18 +52,18 @@
|
||||
if ( /([.~#])$/.test(memberof) ) { // like @memberof foo# or @memberof foo~
|
||||
path = memberof + name;
|
||||
scope = RegExp.$1;
|
||||
if (name) { doclet.addTag('scope', scopeModes[scope]); }
|
||||
if (name) { doclet.addTag('scope', puncToScope[scope]); }
|
||||
}
|
||||
else {
|
||||
scope = doclet.getScope();
|
||||
|
||||
|
||||
if (!scope) {
|
||||
scope = 'static'; // default scope is static
|
||||
if (name) { doclet.addTag('scope', 'static'); }
|
||||
path = memberof + '.' + name;
|
||||
}
|
||||
else {
|
||||
path = memberof + (scope === 'inner'? '~':'#') + name;
|
||||
path = memberof + (scopeToPunc[scope] || '.') + name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -72,7 +73,7 @@
|
||||
|
||||
if (prefix) {
|
||||
doclet.setTag('memberof', prefix);
|
||||
if (name) { doclet.addTag('scope', scopeModes[scope]); }
|
||||
if (name) { doclet.addTag('scope', puncToScope[scope]); }
|
||||
}
|
||||
else if (name) {
|
||||
// global symbol
|
||||
|
||||
@ -12,7 +12,8 @@
|
||||
function visitNode(node) {
|
||||
var commentSrc = '',
|
||||
thisDoclet = null,
|
||||
thisDocletName = '';
|
||||
thisDocletName = '',
|
||||
thisDocletPath = '';
|
||||
|
||||
|
||||
// look for all comments that have names provided
|
||||
@ -80,6 +81,7 @@
|
||||
|
||||
if (commentSrc) {
|
||||
commentSrc = '' + commentSrc;
|
||||
|
||||
thisDoclet = doclet.makeDoclet(commentSrc, node, currentSourceName);
|
||||
thisDocletName = thisDoclet.tagValue('name');
|
||||
nodeKind = thisDoclet.tagValue('isa');
|
||||
@ -104,6 +106,7 @@
|
||||
else { // an uncommented objlit or anonymous function?
|
||||
|
||||
// this thing may have commented members, so keep a ref to the thing but don't add it to the doclets list
|
||||
|
||||
thisDoclet = doclet.makeDoclet('[[undocumented]]', node, currentSourceName);
|
||||
nodeName = name.resolveThis(nodeName, node, thisDoclet);
|
||||
|
||||
@ -129,8 +132,9 @@
|
||||
commentSrc = (counter++ === 0 && !n.jsDoc)? node.jsDoc : n.jsDoc;
|
||||
if (commentSrc) {
|
||||
thisDoclet = doclet.makeDoclet('' + commentSrc, node, currentSourceName);
|
||||
thisDocletName = thisDoclet.tagValue('path');
|
||||
nodeKind = thisDoclet.tagValue('isa');
|
||||
thisDocletPath = thisDoclet.tagValue('path');
|
||||
thisDocletName = thisDoclet.tagValue('name');
|
||||
|
||||
if (!thisDoclet.hasTag('isa') && val) { // guess isa from the source code
|
||||
if (val.type == Token.FUNCTION) {
|
||||
thisDoclet.addTag('isa', 'method');
|
||||
@ -139,20 +143,26 @@
|
||||
thisDoclet.addTag('isa', 'property');
|
||||
}
|
||||
}
|
||||
|
||||
if (!thisDocletName ) { // guess name from the source code
|
||||
//thisDocletName = n.target.string;
|
||||
thisDocletName = name.resolveInner(n.target.string, node, thisDoclet);
|
||||
thisDoclet.setName(thisDocletName);
|
||||
|
||||
if (!thisDocletName) {
|
||||
thisDocletName = n.target.string;
|
||||
if (!thisDocletPath) { // guess path from the source code
|
||||
thisDocletPath = name.resolveInner(thisDocletName, node, thisDoclet);
|
||||
thisDoclet.setName(thisDocletPath);
|
||||
}
|
||||
else {
|
||||
thisDoclet.setName(thisDocletName);
|
||||
}
|
||||
doclets.addDoclet(thisDoclet);
|
||||
}
|
||||
|
||||
if (val) name.refs.push([val, thisDoclet]);
|
||||
if (val) { name.refs.push([val, thisDoclet]); }
|
||||
}
|
||||
else { // an uncommented objlit or anonymous function?
|
||||
var nodeName = nodeToString(n.target);
|
||||
// this thing may have commented members, so keep a ref to the thing but don't add it to the doclets list
|
||||
thisDoclet = doclet.makeDoclet('[[undocumented]]', n.target, currentSourceName);
|
||||
|
||||
nodeName = name.resolveInner(nodeName, n.target, thisDoclet);
|
||||
thisDoclet.setName(nodeName);
|
||||
|
||||
|
||||
44
test/samples/tag_member.js
Normal file
44
test/samples/tag_member.js
Normal file
@ -0,0 +1,44 @@
|
||||
|
||||
/** @namespace foo */
|
||||
|
||||
/** @constructor bar */
|
||||
|
||||
/**
|
||||
@method fah
|
||||
@memberof foo#
|
||||
*/
|
||||
|
||||
/**
|
||||
@property bah
|
||||
@member bar
|
||||
*/
|
||||
|
||||
/**
|
||||
@inner
|
||||
@property bish
|
||||
@member bar
|
||||
*/
|
||||
|
||||
/**
|
||||
@scope instance
|
||||
@property bosh
|
||||
@member bar
|
||||
*/
|
||||
|
||||
/** An unnamed aliased static var
|
||||
@static
|
||||
@property
|
||||
@memberof foo
|
||||
*/
|
||||
var bar = 1;
|
||||
var foo = function() {}; foo.bar = bar;
|
||||
|
||||
/** An unnamed, aliased inner var
|
||||
@inner
|
||||
@property
|
||||
@memberof foz
|
||||
*/
|
||||
var baz = 1;
|
||||
(function(v) {
|
||||
foz = function() {var baz = v; };
|
||||
})(baz);
|
||||
@ -2,9 +2,7 @@
|
||||
@function
|
||||
*/
|
||||
function outie() {
|
||||
/** An inner function
|
||||
@function
|
||||
*/
|
||||
/** An inner function */
|
||||
function innie(){}
|
||||
}
|
||||
|
||||
@ -18,9 +16,7 @@ outie.stat = function() {
|
||||
@function
|
||||
*/
|
||||
var varoutie = function() {
|
||||
/** An inner var function
|
||||
@function
|
||||
*/
|
||||
var varinnie = function() {
|
||||
}
|
||||
/** An inner var function */
|
||||
var varinnie = function() {
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,7 +118,6 @@
|
||||
var foo = {}, onShow, callbacks = [function(){}];
|
||||
/** @constructor bar */
|
||||
|
||||
|
||||
/** @property foo.fah */
|
||||
|
||||
/** @property {string|number} bar.bah Here is a description. */
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
tag: require('jsdoc/tag'),
|
||||
parser: require('jsdoc/parser')
|
||||
};
|
||||
jsdoc.parser.parseFiles(BASEDIR + 'test/tests/14_tag_member.js');
|
||||
jsdoc.parser.parseFiles(BASEDIR + 'test/samples/tag_member.js');
|
||||
doclets = jsdoc.parser.result.map(function($){ return $.toObject(); });
|
||||
|
||||
});
|
||||
@ -121,33 +121,3 @@
|
||||
|
||||
});
|
||||
})();
|
||||
|
||||
(function testarea() {
|
||||
|
||||
/** @namespace foo */
|
||||
|
||||
/** @constructor bar */
|
||||
|
||||
/**
|
||||
@method fah
|
||||
@memberof foo#
|
||||
*/
|
||||
|
||||
/**
|
||||
@property bah
|
||||
@member bar
|
||||
*/
|
||||
|
||||
/**
|
||||
@inner
|
||||
@property bish
|
||||
@member bar
|
||||
*/
|
||||
|
||||
/**
|
||||
@scope instance
|
||||
@property bosh
|
||||
@member bar
|
||||
*/
|
||||
|
||||
})();
|
||||
Loading…
x
Reference in New Issue
Block a user