Skip to content

Commit

Permalink
build: fix duplicate members in dgeni docs (#4956)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
devversion authored and andrewseguin committed Jun 5, 2017
1 parent 98ce635 commit 84c80ec
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 81 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"chalk": "^1.1.3",
"conventional-changelog": "^1.1.3",
"dgeni": "^0.4.7",
"dgeni-packages": "^0.19.0",
"dgeni-packages": "^0.19.1",
"firebase": "^4.0.0",
"firebase-admin": "^5.0.0",
"firebase-tools": "^3.9.0",
Expand Down
2 changes: 0 additions & 2 deletions tools/dgeni/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ const dgeniPackageDeps = [

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

.processor(require('./processors/link-inherited-docs'))

// Processor that filters out symbols that should not be shown in the docs.
.processor(require('./processors/docs-private-filter'))

Expand Down
32 changes: 7 additions & 25 deletions tools/dgeni/processors/categorizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ module.exports = function categorizer() {
* - Identifies directives, services or NgModules and marks them them in class-doc.
*/
function decorateClassDoc(classDoc) {
// Resolve all methods and properties from the classDoc. Includes inherited docs.
classDoc.methods = resolveMethods(classDoc);
classDoc.properties = resolveProperties(classDoc);
// Resolve all methods and properties from the classDoc.
classDoc.methods = classDoc.members.filter(isMethod).filter(filterDuplicateMembers);
classDoc.properties = classDoc.members.filter(isProperty).filter(filterDuplicateMembers);

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

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

/**
Expand All @@ -90,29 +90,11 @@ module.exports = function categorizer() {
}
};

/** Walks through all inherited docs and collects public methods. */
function resolveMethods(classDoc) {
let methods = classDoc.members.filter(isMethod);

if (classDoc.inheritedDoc) {
methods = methods.concat(resolveMethods(classDoc.inheritedDoc));
}

return methods;
/** Filters any duplicate classDoc members from an array */
function filterDuplicateMembers(item, _index, array) {
return array.filter((memberDoc, i) => memberDoc.name === item.name)[0] === item;
}

/** Walks through all inherited docs and collects public properties. */
function resolveProperties(classDoc) {
let properties = classDoc.members.filter(isProperty);

if (classDoc.inheritedDoc) {
properties = properties.concat(resolveProperties(classDoc.inheritedDoc));
}

return properties;
}


/**
* The `parameters` property are the parameters extracted from TypeScript and are strings
* of the form "propertyName: propertyType" (literally what's written in the source).
Expand Down
53 changes: 0 additions & 53 deletions tools/dgeni/processors/link-inherited-docs.js

This file was deleted.

0 comments on commit 84c80ec

Please sign in to comment.