Skip to content

Commit

Permalink
fix(datepicker): generate api docs (#4756)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jelbourn authored and mmalerba committed May 31, 2017
1 parent b3b6fda commit be8d3b2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
7 changes: 2 additions & 5 deletions src/lib/datepicker/datepicker-toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {MdDatepickerIntl} from './datepicker-intl';
template: '',
styleUrls: ['datepicker-toggle.css'],
host: {
'[attr.type]': 'type',
'[class.mat-datepicker-toggle]': 'true',
'type': 'button',
'class': 'mat-datepicker-toggle',
'[attr.aria-label]': '_intl.openCalendarLabel',
'(click)': '_open($event)',
},
Expand All @@ -21,9 +21,6 @@ export class MdDatepickerToggle<D> {
/** Datepicker instance that the button will toggle. */
@Input('mdDatepickerToggle') datepicker: MdDatepicker<D>;

/** Type of the button. */
@Input() type: string = 'button';

@Input('matDatepickerToggle')
get _datepicker() { return this.datepicker; }
set _datepicker(v: MdDatepicker<D>) { this.datepicker = v; }
Expand Down
2 changes: 1 addition & 1 deletion src/lib/datepicker/datepicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ let datepickerUid = 0;
* MdCalendar directly as the content so we can control the initial focus. This also gives us a
* place to put additional features of the popup that are not part of the calendar itself in the
* future. (e.g. confirmation buttons).
* @docs-internal
* @docs-private
*/
@Component({
moduleId: module.id,
Expand Down
3 changes: 2 additions & 1 deletion tools/dgeni/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -143,4 +144,4 @@ let apiDocsPackage = new DgeniPackage('material2-api-docs', dgeniPackageDeps)
});


module.exports = apiDocsPackage;
module.exports = apiDocsPackage;
20 changes: 16 additions & 4 deletions tools/dgeni/processors/categorizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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));
Expand Down Expand Up @@ -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');
}
Expand Down

0 comments on commit be8d3b2

Please sign in to comment.