Skip to content

Commit 5711c23

Browse files
committed
feat: add interface dependencies
1 parent 407a434 commit 5711c23

File tree

4 files changed

+80
-27
lines changed

4 files changed

+80
-27
lines changed

lib/jsdoc/augment.js

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function mapDependencies(index, propertyName) {
1717
var dependencies = {};
1818
var doc;
1919
var doclets;
20-
var kinds = ['class', 'external', 'interface', 'mixin'];
20+
var kinds = ['class', 'external', 'interface', 'mixin', 'typedef'];
2121
var len = 0;
2222

2323
Object.keys(index).forEach(function(indexName) {
@@ -227,6 +227,37 @@ function getInheritedAdditions(doclets, docs, index) {
227227
// doclets will be undefined if the inherited symbol isn't documented
228228
doclets = doclets || [];
229229

230+
// typedef
231+
doclets.filter(function(doclet) {
232+
parents = doclet.augments;
233+
234+
if (doclet.kind !== 'typedef' || !parents || !parents.length) {
235+
return false;
236+
}
237+
238+
return true;
239+
}).forEach(function(doclet) {
240+
parents = doclet.augments;
241+
242+
parents.forEach(function(p) {
243+
if (p.indexOf('$ts:') === 0) {
244+
p = p.replace('$ts:', '');
245+
var match = p.match(/^[a-zA-Z0-9]{2,}/);
246+
247+
if (match) {
248+
p = match[0];
249+
}
250+
}
251+
252+
var documented = docs.index.documented;
253+
var parentDoc = documented[p] && documented[p][0];
254+
255+
if (!parentDoc || !parentDoc.properties || !parentDoc.properties.length) {
256+
return;
257+
}
258+
doclet.properties = parentDoc.properties.concat(doclet.properties);
259+
});
260+
});
230261
for (var i = 0, ii = doclets.length; i < ii; i++) {
231262
doc = doclets[i];
232263
parents = doc.augments;

lib/jsdoc/doclet.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,13 @@ Doclet.prototype.postTypedef = function() {
393393
var interfaceInfo = TypeScriptParser.find('TSInterfaceDeclaration', this.meta.code.node);
394394

395395
if (interfaceInfo) {
396+
var superInterfaces = interfaceInfo.extends || [];
397+
398+
if ((!this.augments || !this.augments.length)) {
399+
this.augments = superInterfaces.map(function(superInterface) {
400+
return superInterface.typeId(self.filename);
401+
});
402+
}
396403
if (interfaceInfo.typeParameters.string) {
397404
this.typeParameters = interfaceInfo.typeParameters;
398405
}

package-lock.json

Lines changed: 39 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@daybrush/jsdoc",
3-
"version": "0.3.6",
3+
"version": "0.3.7-rc3",
44
"description": "An API documentation generator for JavaScript and Typescript.",
55
"keywords": [
66
"documentation",
@@ -20,7 +20,7 @@
2020
"@babel/parser": "^7.2.3",
2121
"@babel/types": "^7.2.2",
2222
"@daybrush/utils": "^0.4.0",
23-
"ast-parser": "^0.0.1",
23+
"ast-parser": "^0.0.3",
2424
"bluebird": "~3.5.0",
2525
"catharsis": "~0.8.9",
2626
"escape-string-regexp": "~1.0.5",

0 commit comments

Comments
 (0)