fix(datepicker): generate api docs (#4756)

This also adds handling for directives with generics, which we have not had before. Dgeni treats this as "members" and they need to be disambiguated from properties.
This commit is contained in:
Jeremy Elbourn
2017-05-30 17:00:05 -07:00
committed by mmalerba
parent b3b6fdad1a
commit be8d3b23d2
4 changed files with 21 additions and 11 deletions
+2 -1
View File
@@ -91,6 +91,7 @@ let apiDocsPackage = new DgeniPackage('material2-api-docs', dgeniPackageDeps)
'checkbox/index.ts',
'chips/index.ts',
'core/index.ts',
'datepicker/index.ts',
'dialog/index.ts',
'grid-list/index.ts',
'icon/index.ts',
@@ -143,4 +144,4 @@ let apiDocsPackage = new DgeniPackage('material2-api-docs', dgeniPackageDeps)
});
module.exports = apiDocsPackage;
module.exports = apiDocsPackage;
+16 -4
View File
@@ -90,9 +90,9 @@ module.exports = function categorizer() {
}
};
/** Function that walks through all inherited docs and collects public methods. */
/** Walks through all inherited docs and collects public methods. */
function resolveMethods(classDoc) {
let methods = classDoc.members.filter(member => member.hasOwnProperty('parameters'));
let methods = classDoc.members.filter(isMethod);
if (classDoc.inheritedDoc) {
methods = methods.concat(resolveMethods(classDoc.inheritedDoc));
@@ -101,9 +101,9 @@ function resolveMethods(classDoc) {
return methods;
}
/** Function that walks through all inherited docs and collects public properties. */
/** Walks through all inherited docs and collects public properties. */
function resolveProperties(classDoc) {
let properties = classDoc.members.filter(member => !member.hasOwnProperty('parameters'));
let properties = classDoc.members.filter(isProperty);
if (classDoc.inheritedDoc) {
properties = properties.concat(resolveProperties(classDoc.inheritedDoc));
@@ -153,6 +153,18 @@ function normalizeMethodParameters(method) {
}
}
function isMethod(doc) {
return doc.hasOwnProperty('parameters');
}
function isGenericTypeParameter(doc) {
return doc.classDoc.typeParams && `<${doc.name}>` === doc.classDoc.typeParams;
}
function isProperty(doc) {
return doc.docType === 'member' && !isMethod(doc) && !isGenericTypeParameter(doc);
}
function isDirective(doc) {
return hasClassDecorator(doc, 'Component') || hasClassDecorator(doc, 'Directive');
}