Skip to content

Commit e372596

Browse files
crisbetojelbourn
authored andcommitted
docs: add jsdoc annotations everywhere (#2321)
* docs: add jsdoc annotations everywhere Adds JSDoc annotations to all of the public properties and methods that were missing them. Also cleans up some random issues that were noticed while going through everything. * Remove the types from the @return annotations and add return type where missing. * Remove @docs-private from the lifecycle hooks. * Typo. * Better line wrapping.
1 parent 9fea175 commit e372596

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+725
-341
lines changed

src/lib/button-toggle/button-toggle.ts

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
DefaultStyleCompatibilityModeModule,
2727
} from '../core';
2828

29-
29+
/** Acceptable types for a button toggle. */
3030
export type ToggleType = 'checkbox' | 'radio';
3131

3232

@@ -102,6 +102,7 @@ export class MdButtonToggleGroup implements AfterViewInit, ControlValueAccessor
102102
this._isInitialized = true;
103103
}
104104

105+
/** `name` attribute for the underlying `input` element. */
105106
@Input()
106107
get name(): string {
107108
return this._name;
@@ -112,6 +113,7 @@ export class MdButtonToggleGroup implements AfterViewInit, ControlValueAccessor
112113
this._updateButtonToggleNames();
113114
}
114115

116+
/** Whether the toggle group is disabled. */
115117
@Input()
116118
get disabled(): boolean {
117119
return this._disabled;
@@ -121,6 +123,7 @@ export class MdButtonToggleGroup implements AfterViewInit, ControlValueAccessor
121123
this._disabled = coerceBooleanProperty(value);
122124
}
123125

126+
/** Whether the toggle group is vertical. */
124127
@Input()
125128
get vertical(): boolean {
126129
return this._vertical;
@@ -130,6 +133,7 @@ export class MdButtonToggleGroup implements AfterViewInit, ControlValueAccessor
130133
this._vertical = coerceBooleanProperty(value);
131134
}
132135

136+
/** Value of the toggle group. */
133137
@Input()
134138
get value(): any {
135139
return this._value;
@@ -149,6 +153,7 @@ export class MdButtonToggleGroup implements AfterViewInit, ControlValueAccessor
149153
}
150154
}
151155

156+
/** Whether the toggle group is selected. */
152157
@Input()
153158
get selected() {
154159
return this._selected;
@@ -199,17 +204,28 @@ export class MdButtonToggleGroup implements AfterViewInit, ControlValueAccessor
199204
this._change.emit(event);
200205
}
201206

202-
/** Implemented as part of ControlValueAccessor. */
207+
/**
208+
* Sets the model value. Implemented as part of ControlValueAccessor.
209+
* @param value Value to be set to the model.
210+
*/
203211
writeValue(value: any) {
204212
this.value = value;
205213
}
206214

207-
/** Implemented as part of ControlValueAccessor. */
215+
/**
216+
* Registers a callback that will be triggered when the value has changed.
217+
* Implemented as part of ControlValueAccessor.
218+
* @param fn On change callback function.
219+
*/
208220
registerOnChange(fn: (value: any) => void) {
209221
this._controlValueAccessorChangeFn = fn;
210222
}
211223

212-
/** Implemented as part of ControlValueAccessor. */
224+
/**
225+
* Registers a callback that will be triggered when the control has been touched.
226+
* Implemented as part of ControlValueAccessor.
227+
* @param fn On touch callback function.
228+
*/
213229
registerOnTouched(fn: any) {
214230
this.onTouched = fn;
215231
}
@@ -230,6 +246,7 @@ export class MdButtonToggleGroupMultiple {
230246
/** Whether the button toggle group should be vertical. */
231247
private _vertical: boolean = false;
232248

249+
/** Whether the toggle group is disabled. */
233250
@Input()
234251
get disabled(): boolean {
235252
return this._disabled;
@@ -239,6 +256,7 @@ export class MdButtonToggleGroupMultiple {
239256
this._disabled = (value != null && value !== false) ? true : null;
240257
}
241258

259+
/** Whether the toggle group is vertical. */
242260
@Input()
243261
get vertical(): boolean {
244262
return this._vertical;
@@ -250,6 +268,7 @@ export class MdButtonToggleGroupMultiple {
250268

251269
}
252270

271+
/** Single button inside of a toggle group. */
253272
@Component({
254273
moduleId: module.id,
255274
selector: 'md-button-toggle',
@@ -332,10 +351,12 @@ export class MdButtonToggle implements OnInit {
332351
}
333352
}
334353

354+
/** Unique ID for the underlying `input` element. */
335355
get inputId(): string {
336356
return `${this.id}-input`;
337357
}
338358

359+
/** Whether the button is checked. */
339360
@HostBinding('class.md-button-toggle-checked')
340361
@Input()
341362
get checked(): boolean {
@@ -380,6 +401,7 @@ export class MdButtonToggle implements OnInit {
380401
this._change.emit(event);
381402
}
382403

404+
/** Whether the button is disabled. */
383405
@HostBinding('class.md-button-toggle-disabled')
384406
@Input()
385407
get disabled(): boolean {
@@ -425,6 +447,7 @@ export class MdButtonToggle implements OnInit {
425447
event.stopPropagation();
426448
}
427449

450+
/** Focuses the button. */
428451
focus() {
429452
this._renderer.invokeElementMethod(this._inputElement.nativeElement, 'focus');
430453
}

src/lib/button/button.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ import {ViewportRuler} from '../core/overlay/position/viewport-ruler';
1717
// TODO(jelbourn): Make the `isMouseDown` stuff done with one global listener.
1818
// TODO(kara): Convert attribute selectors to classes when attr maps become available
1919

20-
20+
/**
21+
* Material design button.
22+
*/
2123
@Component({
2224
moduleId: module.id,
2325
selector: 'button[md-button], button[md-raised-button], button[md-icon-button], ' +
@@ -114,6 +116,9 @@ export class MdButton {
114116
}
115117
}
116118

119+
/**
120+
* Raised Material design button.
121+
*/
117122
@Component({
118123
moduleId: module.id,
119124
selector: 'a[md-button], a[md-raised-button], a[md-icon-button], a[md-fab], a[md-mini-fab]',

src/lib/card/card.ts

Lines changed: 19 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,17 @@ export class MdCardActions {}
5050
export class MdCardFooter {}
5151

5252

53-
/*
54-
55-
<md-card> is a basic content container component that adds the styles of a material design card.
56-
57-
While you can use this component alone,
58-
it also provides a number of preset styles for common card sections, including:
59-
- md-card-title
60-
- md-card-subtitle
61-
- md-card-content
62-
- md-card-actions
63-
- md-card-footer
64-
65-
You can see some examples of cards here:
66-
http://embed.plnkr.co/s5O4YcyvbLhIApSrIhtj/
67-
68-
TODO(kara): update link to demo site when it exists
69-
70-
*/
71-
53+
/**
54+
* A basic content container component that adds the styles of a Material design card.
55+
*
56+
* While this component can be used alone, it also provides a number
57+
* of preset styles for common card sections, including:
58+
* - md-card-title
59+
* - md-card-subtitle
60+
* - md-card-content
61+
* - md-card-actions
62+
* - md-card-footer
63+
*/
7264
@Component({
7365
moduleId: module.id,
7466
selector: 'md-card, mat-card',
@@ -80,20 +72,10 @@ it also provides a number of preset styles for common card sections, including:
8072
export class MdCard {}
8173

8274

83-
/* The following components don't have any behavior.
84-
They simply use content projection to wrap user content
85-
for flex layout purposes in <md-card> (and thus allow a cleaner, boilerplate-free API).
86-
87-
88-
<md-card-header> is a component intended to be used within the <md-card> component.
89-
It adds styles for a preset header section (i.e. a title, subtitle, and avatar layout).
90-
91-
You can see an example of a card with a header here:
92-
http://embed.plnkr.co/tvJl19z3gZTQd6WmwkIa/
93-
94-
TODO(kara): update link to demo site when it exists
95-
*/
96-
75+
/**
76+
* Component intended to be used within the `<md-card>` component. It adds styles for a
77+
* preset header section (i.e. a title, subtitle, and avatar layout).
78+
*/
9779
@Component({
9880
moduleId: module.id,
9981
selector: 'md-card-header, mat-card-header',
@@ -103,17 +85,11 @@ TODO(kara): update link to demo site when it exists
10385
})
10486
export class MdCardHeader {}
10587

106-
/*
107-
108-
<md-card-title-group> is a component intended to be used within the <md-card> component.
109-
It adds styles for a preset layout that groups an image with a title section.
110-
111-
You can see an example of a card with a title-group section here:
112-
http://embed.plnkr.co/EDfgCF9eKcXjini1WODm/
113-
114-
TODO(kara): update link to demo site when it exists
115-
*/
11688

89+
/**
90+
* Component intended to be used within the <md-card> component. It adds styles for a preset
91+
* layout that groups an image with a title section.
92+
*/
11793
@Component({
11894
moduleId: module.id,
11995
selector: 'md-card-title-group, mat-card-title-group',

src/lib/checkbox/checkbox.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class MdCheckboxChange {
5757

5858
/**
5959
* A material design checkbox component. Supports all of the functionality of an HTML5 checkbox,
60-
* and exposes a similar API. An MdCheckbox can be either checked, unchecked, indeterminate, or
60+
* and exposes a similar API. A MdCheckbox can be either checked, unchecked, indeterminate, or
6161
* disabled. Note that all additional accessibility attributes are taken care of by the component,
6262
* so there is no need to provide them yourself. However, if you want to omit a label and still
6363
* have the checkbox be accessible, you may supply an [aria-label] input.
@@ -148,7 +148,7 @@ export class MdCheckbox implements ControlValueAccessor {
148148
/** Event emitted when the checkbox's `checked` value changes. */
149149
@Output() change: EventEmitter<MdCheckboxChange> = new EventEmitter<MdCheckboxChange>();
150150

151-
/** The native `<input type=checkbox> element */
151+
/** The native `<input type="checkbox"> element */
152152
@ViewChild('input') _inputElement: ElementRef;
153153

154154
/**
@@ -239,22 +239,36 @@ export class MdCheckbox implements ControlValueAccessor {
239239
return this.disableRipple || this.disabled;
240240
}
241241

242-
/** Implemented as part of ControlValueAccessor. */
242+
/**
243+
* Sets the model value. Implemented as part of ControlValueAccessor.
244+
* @param value Value to be set to the model.
245+
*/
243246
writeValue(value: any) {
244247
this.checked = !!value;
245248
}
246249

247-
/** Implemented as part of ControlValueAccessor. */
250+
/**
251+
* Registers a callback to be triggered when the value has changed.
252+
* Implemented as part of ControlValueAccessor.
253+
* @param fn Function to be called on change.
254+
*/
248255
registerOnChange(fn: (value: any) => void) {
249256
this._controlValueAccessorChangeFn = fn;
250257
}
251258

252-
/** Implemented as part of ControlValueAccessor. */
259+
/**
260+
* Registers a callback to be triggered when the control has been touched.
261+
* Implemented as part of ControlValueAccessor.
262+
* @param fn Callback to be triggered when the checkbox is touched.
263+
*/
253264
registerOnTouched(fn: any) {
254265
this.onTouched = fn;
255266
}
256267

257-
/** Implemented as a part of ControlValueAccessor. */
268+
/**
269+
* Sets the checkbox's disabled state. Implemented as a part of ControlValueAccessor.
270+
* @param isDisabled Whether the checkbox should be disabled.
271+
*/
258272
setDisabledState(isDisabled: boolean) {
259273
this.disabled = isDisabled;
260274
}

src/lib/chips/chip-list.spec.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ describe('MdChipList', () => {
4747
});
4848

4949
it('focuses the first chip on focus', () => {
50-
let FOCUS_EVENT: Event = {} as Event;
51-
52-
chipListInstance.focus(FOCUS_EVENT);
50+
chipListInstance.focus();
5351
fixture.detectChanges();
5452

5553
expect(manager.focusedItemIndex).toBe(0);
@@ -109,15 +107,14 @@ describe('MdChipList', () => {
109107
});
110108

111109
it('SPACE selects/deselects the currently focused chip', () => {
112-
let FOCUS_EVENT: Event = {} as Event;
113110
let SPACE_EVENT: KeyboardEvent = new FakeEvent(SPACE) as KeyboardEvent;
114111
let firstChip: MdChip = chips.toArray()[0];
115112

116113
spyOn(testComponent, 'chipSelect');
117114
spyOn(testComponent, 'chipDeselect');
118115

119116
// Make sure we have the first chip focused
120-
chipListInstance.focus(FOCUS_EVENT);
117+
chipListInstance.focus();
121118

122119
// Use the spacebar to select the chip
123120
chipListInstance._keydown(SPACE_EVENT);
@@ -144,14 +141,13 @@ describe('MdChipList', () => {
144141
});
145142

146143
it('SPACE ignores selection', () => {
147-
let FOCUS_EVENT: Event = {} as Event;
148144
let SPACE_EVENT: KeyboardEvent = new FakeEvent(SPACE) as KeyboardEvent;
149145
let firstChip: MdChip = chips.toArray()[0];
150146

151147
spyOn(testComponent, 'chipSelect');
152148

153149
// Make sure we have the first chip focused
154-
chipListInstance.focus(FOCUS_EVENT);
150+
chipListInstance.focus();
155151

156152
// Use the spacebar to attempt to select the chip
157153
chipListInstance._keydown(SPACE_EVENT);

src/lib/chips/chip-list.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ export class MdChipList implements AfterContentInit {
6161
/** The chip components contained within this chip list. */
6262
chips: QueryList<MdChip>;
6363

64-
constructor(private _elementRef: ElementRef) {
65-
}
64+
constructor(private _elementRef: ElementRef) { }
6665

6766
ngAfterContentInit(): void {
6867
this._keyManager = new ListKeyManager(this.chips).withFocusWrap();
@@ -89,16 +88,15 @@ export class MdChipList implements AfterContentInit {
8988
}
9089

9190
/**
92-
* Programmatically focus the chip list. This in turn focuses the first non-disabled chip in this
93-
* chip list.
94-
*
95-
* TODO: ARIA says this should focus the first `selected` chip.
91+
* Programmatically focus the chip list. This in turn focuses the first
92+
* non-disabled chip in this chip list.
9693
*/
97-
focus(event: Event) {
94+
focus() {
95+
// TODO: ARIA says this should focus the first `selected` chip.
9896
this._keyManager.focusFirstItem();
9997
}
10098

101-
/** Pass relevant key presses to our key manager. */
99+
/** Passes relevant key presses to our key manager. */
102100
_keydown(event: KeyboardEvent) {
103101
switch (event.keyCode) {
104102
case SPACE:
@@ -190,7 +188,7 @@ export class MdChipList implements AfterContentInit {
190188
* Utility to ensure all indexes are valid.
191189
*
192190
* @param index The index to be checked.
193-
* @returns {boolean} True if the index is valid for our list of chips.
191+
* @returns True if the index is valid for our list of chips.
194192
*/
195193
private _isValidIndex(index: number): boolean {
196194
return index >= 0 && index < this.chips.length;

0 commit comments

Comments
 (0)