Skip to content

Commit

Permalink
feat(override): description of super class method.
Browse files Browse the repository at this point in the history
  • Loading branch information
h13i32maru committed Dec 30, 2016
1 parent 7161663 commit 7b515f0
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/Publisher/Builder/DocBuilder.js
Expand Up @@ -452,7 +452,7 @@ export default class DocBuilder {
ice.text('async', doc.async ? 'async' : ''); ice.text('async', doc.async ? 'async' : '');
ice.text('name', doc.name); ice.text('name', doc.name);
ice.load('signature', this._buildSignatureHTML(doc)); ice.load('signature', this._buildSignatureHTML(doc));
ice.load('description', doc.description); ice.load('description', doc.description || this._buildOverrideMethodDescription(doc));
ice.text('abstract', doc.abstract ? 'abstract' : ''); ice.text('abstract', doc.abstract ? 'abstract' : '');
ice.text('access', doc.access); ice.text('access', doc.access);
if (['get', 'set'].includes(doc.kind)) { if (['get', 'set'].includes(doc.kind)) {
Expand Down Expand Up @@ -1026,6 +1026,31 @@ export default class DocBuilder {
return ''; return '';
} }


/**
* build method of ancestor class description.
* @param {DocObject} doc - target doc object.
* @returns {string} description. if doc does not override ancestor method, returns empty.
* @private
*/
_buildOverrideMethodDescription(doc) {
const parentDoc = this._findByName(doc.memberof)[0];
if (!parentDoc) return '';
if (!parentDoc._custom_extends_chains) return '';

const chains = [...parentDoc._custom_extends_chains].reverse();
for (const longname of chains) {
const superClassDoc = this._findByName(longname)[0];
if (!superClassDoc) continue;

const superMethodDoc = this._find({name: doc.name, memberof: superClassDoc.longname})[0];
if (!superMethodDoc) continue;

if (superMethodDoc.description) return superMethodDoc.description;
}

return '';
}

_buildDecoratorHTML(doc) { _buildDecoratorHTML(doc) {
if (!doc.decorators) return ''; if (!doc.decorators) return '';


Expand Down

0 comments on commit 7b515f0

Please sign in to comment.