Skip to content

Commit be8d3b2

Browse files
jelbournmmalerba
authored andcommitted
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.
1 parent b3b6fda commit be8d3b2

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

src/lib/datepicker/datepicker-toggle.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import {MdDatepickerIntl} from './datepicker-intl';
99
template: '',
1010
styleUrls: ['datepicker-toggle.css'],
1111
host: {
12-
'[attr.type]': 'type',
13-
'[class.mat-datepicker-toggle]': 'true',
12+
'type': 'button',
13+
'class': 'mat-datepicker-toggle',
1414
'[attr.aria-label]': '_intl.openCalendarLabel',
1515
'(click)': '_open($event)',
1616
},
@@ -21,9 +21,6 @@ export class MdDatepickerToggle<D> {
2121
/** Datepicker instance that the button will toggle. */
2222
@Input('mdDatepickerToggle') datepicker: MdDatepicker<D>;
2323

24-
/** Type of the button. */
25-
@Input() type: string = 'button';
26-
2724
@Input('matDatepickerToggle')
2825
get _datepicker() { return this.datepicker; }
2926
set _datepicker(v: MdDatepicker<D>) { this.datepicker = v; }

src/lib/datepicker/datepicker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ let datepickerUid = 0;
4141
* MdCalendar directly as the content so we can control the initial focus. This also gives us a
4242
* place to put additional features of the popup that are not part of the calendar itself in the
4343
* future. (e.g. confirmation buttons).
44-
* @docs-internal
44+
* @docs-private
4545
*/
4646
@Component({
4747
moduleId: module.id,

tools/dgeni/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ let apiDocsPackage = new DgeniPackage('material2-api-docs', dgeniPackageDeps)
9191
'checkbox/index.ts',
9292
'chips/index.ts',
9393
'core/index.ts',
94+
'datepicker/index.ts',
9495
'dialog/index.ts',
9596
'grid-list/index.ts',
9697
'icon/index.ts',
@@ -143,4 +144,4 @@ let apiDocsPackage = new DgeniPackage('material2-api-docs', dgeniPackageDeps)
143144
});
144145

145146

146-
module.exports = apiDocsPackage;
147+
module.exports = apiDocsPackage;

tools/dgeni/processors/categorizer.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ module.exports = function categorizer() {
9090
}
9191
};
9292

93-
/** Function that walks through all inherited docs and collects public methods. */
93+
/** Walks through all inherited docs and collects public methods. */
9494
function resolveMethods(classDoc) {
95-
let methods = classDoc.members.filter(member => member.hasOwnProperty('parameters'));
95+
let methods = classDoc.members.filter(isMethod);
9696

9797
if (classDoc.inheritedDoc) {
9898
methods = methods.concat(resolveMethods(classDoc.inheritedDoc));
@@ -101,9 +101,9 @@ function resolveMethods(classDoc) {
101101
return methods;
102102
}
103103

104-
/** Function that walks through all inherited docs and collects public properties. */
104+
/** Walks through all inherited docs and collects public properties. */
105105
function resolveProperties(classDoc) {
106-
let properties = classDoc.members.filter(member => !member.hasOwnProperty('parameters'));
106+
let properties = classDoc.members.filter(isProperty);
107107

108108
if (classDoc.inheritedDoc) {
109109
properties = properties.concat(resolveProperties(classDoc.inheritedDoc));
@@ -153,6 +153,18 @@ function normalizeMethodParameters(method) {
153153
}
154154
}
155155

156+
function isMethod(doc) {
157+
return doc.hasOwnProperty('parameters');
158+
}
159+
160+
function isGenericTypeParameter(doc) {
161+
return doc.classDoc.typeParams && `<${doc.name}>` === doc.classDoc.typeParams;
162+
}
163+
164+
function isProperty(doc) {
165+
return doc.docType === 'member' && !isMethod(doc) && !isGenericTypeParameter(doc);
166+
}
167+
156168
function isDirective(doc) {
157169
return hasClassDecorator(doc, 'Component') || hasClassDecorator(doc, 'Directive');
158170
}

0 commit comments

Comments
 (0)