Permalink
Browse files

feat(override): description of super class method.

  • Loading branch information...
h13i32maru committed Dec 30, 2016
1 parent 7161663 commit 7b515f0367a386ceb732b4606b96abf24bfab627
Showing with 26 additions and 1 deletion.
  1. +26 −1 src/Publisher/Builder/DocBuilder.js
@@ -452,7 +452,7 @@ export default class DocBuilder {
ice.text('async', doc.async ? 'async' : '');
ice.text('name', doc.name);
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('access', doc.access);
if (['get', 'set'].includes(doc.kind)) {
@@ -1026,6 +1026,31 @@ export default class DocBuilder {
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) {
if (!doc.decorators) return '';

0 comments on commit 7b515f0

Please sign in to comment.