multiple fixes for overridden symbols (#855)

- Don't add an "overrides" property to members that are merely inherited.
- In the template, don't show both "overrides" and "inherited from" for the same member.
This commit is contained in:
Jeff Williams 2014-12-29 15:48:05 -08:00
parent dfdce46683
commit 7e23a68c59
4 changed files with 20 additions and 4 deletions

View File

@ -201,7 +201,12 @@ function getInheritedAdditions(doclets, docs, documented) {
// Indicate what the descendant is overriding. (We only care about the closest
// ancestor. For classes A > B > C, if B#a overrides A#a, and C#a inherits B#a,
// we don't want the doclet for C#a to say that it overrides A#a.)
addDocletProperty([member], 'overrides', members[k].longname);
if (docs.index.longname[member.longname]) {
member.overrides = members[k].longname;
}
else {
delete member.overrides;
}
// Add the ancestor's docs unless the descendant overrides the ancestor AND
// documents the override.

View File

@ -32,7 +32,7 @@ if (data.defaultvalue && (data.defaultvaluetype === 'object' || data.defaultvalu
<dd class="tag-since"><ul class="dummy"><li><?js= since ?></li></ul></dd>
<?js } ?>
<?js if (data.inherited && data.inherits) { ?>
<?js if (data.inherited && data.inherits && !data.overrides) { ?>
<dt class="inherited-from">Inherited From:</dt>
<dd class="inherited-from"><ul class="dummy"><li>
<?js= this.linkto(data.inherits, this.htmlsafe(data.inherits)) ?>

View File

@ -22,6 +22,11 @@ Foo.prototype.method1 = function() {};
*/
Foo.prototype.method2 = function() {};
/**
* Third parent method.
*/
Foo.prototype.method3 = function() {};
/**
* @constructor
* @extends Foo

View File

@ -101,10 +101,16 @@
expect(bazMethod2.inherits).toBe('Bar#method2');
});
it('When the grandparent has a method, and the parent overrides it, the child should say it overrides the parent', function() {
it('When the grandparent has a method, the parent overrides it, and the child inherits it, the child should not say it overrides anything', function() {
var bazMethod2 = docSet.getByLongname('Baz#method2')[0];
expect(bazMethod2.overrides).toBe('Bar#method2');
expect(bazMethod2.overrides).not.toBeDefined();
});
it('When the grandparent has a method, the parent inherits it, and the child overrides it, the child should say it overrides the parent', function() {
var bazMethod3 = docSet.getByLongname('Baz#method3')[0];
expect(bazMethod3.overrides).toBe('Bar#method3');
});
it('When an object is extended, and it overrides an ancestor property, the child does not include docs for the ancestor property.', function() {