Skip to content

Commit 427391e

Browse files
committed
Clean up documentation
1 parent fc43bc3 commit 427391e

7 files changed

Lines changed: 151 additions & 19 deletions

File tree

transforms/helpers/eo-prop/private/abstract.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ type EOPropValue = AST.EOProp['value'] | AST.EOMethod;
1414
/**
1515
* Ember Object Property
1616
*
17-
* A wrapper object for ember object properties
17+
* A wrapper object for Ember Object properties and methods.
18+
*
19+
* Each subclass is required to implement a `build` method that returns the
20+
* appropriate AST node (or array thereof) to be added to the parent
21+
* `EOExtendExpression`'s `ClassBody`.
1822
*/
1923
export default abstract class AbstractEOProp<
2024
P extends AST.EOExpressionProp,

transforms/helpers/eo-prop/private/call-expression/abstract.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ import AbstractEOProp from '../abstract';
88
import type { CallExpressionModifier } from './modifier-helper';
99
import { COMPUTED_DECORATOR_NAME } from '../../../util/index';
1010

11+
/**
12+
* Ember Object Call Expression Property
13+
*
14+
* A wrapper object for Ember Object properties with `CallExpression` values
15+
* to be transformed the appropriate AST node (or array thereof) to be added to
16+
* the parent `EOExtendExpression`'s `ClassBody`.
17+
*
18+
* See each subclass for more details.
19+
*/
1120
export default abstract class AbstractEOCallExpressionProp<
1221
B extends AST.ClassProperty | AST.ClassMethod | AST.ClassMethod[]
1322
> extends AbstractEOProp<AST.EOCallExpressionProp, B> {

transforms/helpers/eo-prop/private/call-expression/function-expression.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,38 @@ import { replaceComputedSuperExpressions as replaceComputedSuperExpression } fro
44
import { assert, defined } from '../../../util/types';
55
import AbstractEOCallExpressionProp from './abstract';
66

7+
/**
8+
* Ember Object Computed Function Expression Property
9+
*
10+
* A wrapper object for Ember Object properties with `FunctionExpression` values
11+
* for computed properties (including computed macros) to be transformed into
12+
* `ClassMethod`s with their appropriate decorators (and any modifiers).
13+
*
14+
* @example
15+
*
16+
* ```
17+
* const MyObject = EmberObject.extend({
18+
* firstName: 'Krystan',
19+
* lastName: 'HuffMenne',
20+
* fName1: alias('firstName'),
21+
* fName2: alias('firstName').readOnly(),
22+
* fullName: computed('firstName', 'lastName', function() {
23+
* return `${firstName} ${lastName}`;
24+
* }),
25+
* // FIXME: Getter/setter version
26+
* });
27+
* ```
28+
*
29+
* transforms into:
30+
*
31+
* ```
32+
* class MyObject extends EmberObject {
33+
* FIXME: Fill in
34+
* }
35+
* ```
36+
*
37+
* @see EOMethod
38+
*/
739
export default class EOComputedFunctionExpressionProp extends AbstractEOCallExpressionProp<AST.ClassMethod> {
840
build(): AST.ClassMethod {
941
const args = this.arguments;

transforms/helpers/eo-prop/private/class-decorator.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,26 @@ import AbstractEOProp from './abstract';
1414
/**
1515
* Ember Object Class Decorator
1616
*
17-
* A wrapper object for ember object properties that should be converted into
18-
* class decorators, including:
19-
* - `@classNames`
20-
* - `@attributeBindings`
21-
* - `@classNameBindings`
22-
* - `@layout`
23-
* - `@tagName`
24-
* - `@templateLayout`
17+
* A wrapper object for Ember Object properties that should be converted into
18+
* class decorators. See `CLASS_DECORATOR_NAMES` for the list of handled
19+
* decorator properties.
20+
*
21+
* @example
22+
*
23+
* ```
24+
* const MyObject = EmberObject.extend({
25+
* tagName: '',
26+
* classNames: ['my-object'],
27+
* });
28+
* ```
29+
*
30+
* transforms into:
31+
*
32+
* ```
33+
* @tagName('')
34+
* @classNames('my-object')
35+
* class MyObject extends EmberObject {
36+
* }
2537
*/
2638
export default class EOClassDecorator extends AbstractEOProp<
2739
AST.EOClassDecoratorProp,

transforms/helpers/eo-prop/private/function-expression.ts

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,34 @@ import type * as AST from '../../ast';
33
import { replaceMethodSuperExpression } from '../../transform-helper';
44
import AbstractEOProp from './abstract';
55

6+
/**
7+
* Ember Object Function Expression Property
8+
*
9+
* A wrapper object for Ember Object properties with `FunctionExpression` values
10+
* to be transformed into `ClassMethod`s.
11+
*
12+
* @example
13+
*
14+
* ```
15+
* const MyObject = EmberObject.extend({
16+
* myMethod: () => {
17+
* this._super(...arguments);
18+
* }
19+
* });
20+
* ```
21+
*
22+
* transforms into:
23+
*
24+
* ```
25+
* class MyObject extends EmberObject {
26+
* myMethod() {
27+
* super.myMethod(...arguments);
28+
* }
29+
* }
30+
* ```
31+
*
32+
* @see EOMethod
33+
*/
634
export default class EOFunctionExpressionProp extends AbstractEOProp<
735
AST.EOFunctionExpressionProp,
836
AST.ClassMethod
@@ -13,11 +41,6 @@ export default class EOFunctionExpressionProp extends AbstractEOProp<
1341

1442
protected override readonly supportsObjectLiteralDecorators = true;
1543

16-
/**
17-
* Transform functions to class methods
18-
*
19-
* For example { foo: function() { }} --> { foo() { }}
20-
*/
2144
build(): AST.ClassMethod {
2245
return replaceMethodSuperExpression(
2346
j.classMethod.from({

transforms/helpers/eo-prop/private/method.ts

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,38 @@ import type * as AST from '../../ast';
33
import { replaceMethodSuperExpression } from '../../transform-helper';
44
import AbstractEOProp from './abstract';
55

6+
/**
7+
* Ember Object Method
8+
*
9+
* A wrapper object for Ember Object methods (including getters and setters) to
10+
* be transformed into `ClassMethod`s.
11+
*
12+
* @example
13+
*
14+
* ```
15+
* const MyObject = EmberObject.extend({
16+
* get myGetter() {},
17+
*
18+
* myMethod() {
19+
* this._super(...arguments);
20+
* }
21+
* });
22+
* ```
23+
*
24+
* transforms into:
25+
*
26+
* ```
27+
* class MyObject extends EmberObject {
28+
* get myGetter() {}
29+
*
30+
* myMethod() {
31+
* super.myMethod(...arguments);
32+
* }
33+
* }
34+
* ```
35+
*
36+
* @see EOFunctionExpressionProp
37+
*/
638
export default class EOMethod extends AbstractEOProp<
739
AST.EOMethod,
840
AST.ClassMethod
@@ -13,11 +45,6 @@ export default class EOMethod extends AbstractEOProp<
1345

1446
protected override readonly supportsObjectLiteralDecorators = true;
1547

16-
/**
17-
* Transform object method to class method
18-
*
19-
* For example { foo() { }} --> { foo() { }}
20-
*/
2148
build(): AST.ClassMethod {
2249
return replaceMethodSuperExpression(
2350
j.classMethod.from({

transforms/helpers/eo-prop/private/simple.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,31 @@ import { createDecoratorWithArgs } from '../../decorator-helper';
44
import logger from '../../log-helper';
55
import AbstractEOProp from './abstract';
66

7+
/**
8+
* Ember Object Simple Property
9+
*
10+
* A wrapper object for Ember Object properties not captured by the other
11+
* `EOProp`/`EOClassDecorator` classes to be transformed into
12+
* `ClassProperties`s.
13+
*
14+
* @example
15+
*
16+
* ```
17+
* const MyObject = EmberObject.extend({
18+
* myMethod: () => {}
19+
* });
20+
* ```
21+
*
22+
* transforms into:
23+
*
24+
* ```
25+
* class MyObject extends EmberObject {
26+
* myMethod() {}
27+
* }
28+
* ```
29+
*
30+
* @see EOMethod
31+
*/
732
export default class EOSimpleProp extends AbstractEOProp<
833
AST.EOSimpleProp,
934
AST.ClassProperty

0 commit comments

Comments
 (0)