Skip to content

Commit 84c80ec

Browse files
devversionandrewseguin
authored andcommitted
build: fix duplicate members in dgeni docs (#4956)
Recently Dgeni switch to a more recent version of TypeScript and now getters and setters are counting as individual members. This causes different properties to show up twice in the API docs. Fixes this temporary by filtering duplicate member docs. Also removes the inhertied docs processor since it doesn't work and needs some more work in the `dgeni-packages` repository. Fixes #4923
1 parent 98ce635 commit 84c80ec

File tree

4 files changed

+8
-81
lines changed

4 files changed

+8
-81
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"chalk": "^1.1.3",
6262
"conventional-changelog": "^1.1.3",
6363
"dgeni": "^0.4.7",
64-
"dgeni-packages": "^0.19.0",
64+
"dgeni-packages": "^0.19.1",
6565
"firebase": "^4.0.0",
6666
"firebase-admin": "^5.0.0",
6767
"firebase-tools": "^3.9.0",

tools/dgeni/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ const dgeniPackageDeps = [
3535

3636
let apiDocsPackage = new DgeniPackage('material2-api-docs', dgeniPackageDeps)
3737

38-
.processor(require('./processors/link-inherited-docs'))
39-
4038
// Processor that filters out symbols that should not be shown in the docs.
4139
.processor(require('./processors/docs-private-filter'))
4240

tools/dgeni/processors/categorizer.js

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ module.exports = function categorizer() {
3333
* - Identifies directives, services or NgModules and marks them them in class-doc.
3434
*/
3535
function decorateClassDoc(classDoc) {
36-
// Resolve all methods and properties from the classDoc. Includes inherited docs.
37-
classDoc.methods = resolveMethods(classDoc);
38-
classDoc.properties = resolveProperties(classDoc);
36+
// Resolve all methods and properties from the classDoc.
37+
classDoc.methods = classDoc.members.filter(isMethod).filter(filterDuplicateMembers);
38+
classDoc.properties = classDoc.members.filter(isProperty).filter(filterDuplicateMembers);
3939

4040
// Call decorate hooks that can modify the method and property docs.
4141
classDoc.methods.forEach(doc => decorateMethodDoc(doc));
@@ -64,7 +64,7 @@ module.exports = function categorizer() {
6464
decoratePublicDoc(methodDoc);
6565

6666
// Mark methods with a `void` return type so we can omit show the return type in the docs.
67-
methodDoc.showReturns = methodDoc.returnType && methodDoc.returnType != 'void';
67+
methodDoc.showReturns = methodDoc.returnType && methodDoc.returnType !== 'void';
6868
}
6969

7070
/**
@@ -90,29 +90,11 @@ module.exports = function categorizer() {
9090
}
9191
};
9292

93-
/** Walks through all inherited docs and collects public methods. */
94-
function resolveMethods(classDoc) {
95-
let methods = classDoc.members.filter(isMethod);
96-
97-
if (classDoc.inheritedDoc) {
98-
methods = methods.concat(resolveMethods(classDoc.inheritedDoc));
99-
}
100-
101-
return methods;
93+
/** Filters any duplicate classDoc members from an array */
94+
function filterDuplicateMembers(item, _index, array) {
95+
return array.filter((memberDoc, i) => memberDoc.name === item.name)[0] === item;
10296
}
10397

104-
/** Walks through all inherited docs and collects public properties. */
105-
function resolveProperties(classDoc) {
106-
let properties = classDoc.members.filter(isProperty);
107-
108-
if (classDoc.inheritedDoc) {
109-
properties = properties.concat(resolveProperties(classDoc.inheritedDoc));
110-
}
111-
112-
return properties;
113-
}
114-
115-
11698
/**
11799
* The `parameters` property are the parameters extracted from TypeScript and are strings
118100
* of the form "propertyName: propertyType" (literally what's written in the source).

tools/dgeni/processors/link-inherited-docs.js

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)