mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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:
@@ -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;
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user