Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Commit 0e0f8d6

Browse files
committed
docs: edit formatter docs
1 parent 048ed5c commit 0e0f8d6

File tree

7 files changed

+67
-28
lines changed

7 files changed

+67
-28
lines changed

lib/formatter/json.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
part of angular.formatter_internal;
22

33
/**
4-
* Allows you to convert a JavaScript object into JSON string. This formatter is
5-
* mostly useful for debugging.
4+
* Converts a JavaScript object into a JSON string.
5+
*
6+
* This formatter is mostly useful for debugging.
67
*
78
* Usage:
89
*

lib/formatter/limit_to.dart

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,28 @@ part of angular.formatter_internal;
22

33
/**
44
* Creates a new List or String containing only a prefix/suffix of the
5-
* elements as specified by the `limit` parameter.
5+
* elements.
6+
*
7+
* The number of elements to return is specified by the `limitTo` parameter.
8+
*
9+
* Usage:
10+
*
11+
* {{ expression | limitTo:_value_ }}
612
*
7-
* When operating on a List, the returned list is always a copy even when all
8-
* the elements are being returned.
913
*
10-
* When the `limit` expression evaluates to a positive integer, `limit` items
11-
* from the beginning of the List/String are returned. When `limit` evaluates
12-
* to a negative integer, `|limit|` items from the end of the List/String are
13-
* returned. If `|limit|` is larger than the size of the List/String, then the
14-
* entire List/String is returned. In the case of a List, a copy of the list is
15-
* returned.
14+
* <div ng-repeat="item in expression | limitTo:_value_">{{item}}</div>
1615
*
17-
* If the `limit` expression evaluates to a null or non-integer, then an empty
18-
* list is returned. If the input is a null List/String, a null is returned.
16+
*
17+
* Where the input expression is a [List] or [String], and `limitTo` evaluates to:
18+
*
19+
* - **a positive integer**: return _value_ items from the beginning of the list or string
20+
* expression.
21+
* - **a negative integer**: return _value_ items from the end of the list or string expression.
22+
* - **null or non-integer**: return an empty list or string.
23+
* - **`|limitTo|` greater than the size of the expression**: return the entire expression.
24+
*
25+
* When operating on a [List], the returned list is always a copy even when all
26+
* the elements are being returned.
1927
*
2028
* Example:
2129
*
@@ -29,7 +37,7 @@ part of angular.formatter_internal;
2937
*
3038
* <li ng-repeat="i in 'abcdefghij' | limitTo:-2">{{i}}</li>
3139
*
32-
* results in
40+
* produces the following:
3341
*
3442
* <li>i</li>
3543
* <li>j</li>

lib/formatter/lowercase.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
part of angular.formatter_internal;
22

33
/**
4-
* Converts string to lowercase.
4+
* Converts a string to lowercase.
55
*
66
* Usage:
77
*

lib/formatter/number.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ part of angular.formatter_internal;
33
/**
44
* Formats a number as text.
55
*
6-
* If the input is not a number an empty string is returned.
6+
* If the input is not a number, an empty string is returned.
77
*
88
*
99
* Usage:
@@ -17,12 +17,14 @@ class Number {
1717
var _nfs = new Map<String, Map<num, NumberFormat>>();
1818

1919
/**
20-
* [value]: the value to format
20+
* Format a number as text.
21+
*
22+
* - `value`: the value to format
23+
* - `fractionSize`: Number of decimal places to round the number to.
24+
*
25+
* When fractionSize is not provided, fraction size is computed from the current locale's number
26+
* formatting pattern. In the case of the default locale, it will be 3.
2127
*
22-
* [fractionSize]: Number of decimal places to round the number to. If this
23-
* is not provided then the fraction size is computed from the current
24-
* locale's number formatting pattern. In the case of the default locale,
25-
* it will be 3.
2628
*/
2729
call(value, [fractionSize = null]) {
2830
if (value is String) value = double.parse(value);

lib/formatter/order_by.dart

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,32 @@ part of angular.formatter_internal;
33
typedef dynamic _Mapper(dynamic e);
44

55
/**
6-
* Orders the provided [Iterable] by the `expression` predicate.
6+
* Orders the the elements of an object by a predicate expression.
7+
*
8+
* Usage:
9+
*
10+
* <div ng-repeat="item in items | orderBy: [+/-]_expression_[:true]">
11+
*
12+
*
13+
* The input must be an [Iterable] object. The expression may be specified as:
14+
*
15+
* - `+`: sort the elements in asending order. This is the default comparator.
16+
* - `-`: sort the elements in descending order.
17+
* - **a string expression**: sort on a decorated/transformed value, such as "lastName",
18+
* or to sort non-primitives values.
19+
* - **a custom callable expression**: an expression that will be called to transform the element
20+
* before a sort.
21+
* - **a list**: the list may consist of either string or callable expressions. A list expression
22+
* indicates a list of fallback expressions to use when a comparision results in the items
23+
* being equal.
24+
*
25+
* If the expression is explicitly empty(`orderBy:```), the elements are sorted in
26+
* ascending order, using the default comparator, `+`.
27+
*
28+
* Last, by appending `:true`, you can set "descending order" to true,
29+
* which has the same effect as the `-` comparator.
30+
*
31+
* # Examples
732
*
833
* Example 1: Simple array and single/empty expression.
934
*
@@ -24,7 +49,7 @@ typedef dynamic _Mapper(dynamic e);
2449
* <ul>
2550
*
2651
* The empty string expression, `''`, here signifies sorting in ascending order
27-
* using the default comparator. Using `'+'` would also work as the `+` prefix
52+
* using the default comparator. Using `'+'` would also work, as the `+` prefix
2853
* is implied.
2954
*
3055
* To sort in descending order, you would use the `'-'` prefix.
@@ -44,7 +69,7 @@ typedef dynamic _Mapper(dynamic e);
4469
*
4570
* Example 2: Complex objects, single expression.
4671
*
47-
* You may provide a more complex expression to sort non-primitives values or
72+
* You may provide a more complex expression to sort non-primitive values or
4873
* if you want to sort on a decorated/transformed value.
4974
*
5075
* e.g. Support you have a list `users` that looks like this:
@@ -135,7 +160,10 @@ class OrderBy implements Function {
135160
}
136161

137162
/**
138-
* expression: String/Function or Array of String/Function.
163+
* Order a list by expression.
164+
*
165+
* - `expression`: String/Function or Array of String/Function.
166+
* - `descending`: When specified, use descending order. (The default is ascending order.)
139167
*/
140168
List call(List items, var expression, [bool descending=false]) {
141169
if (items == null) {

lib/formatter/stringify.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
part of angular.formatter_internal;
22

33
/**
4-
* Allows you to convert an object to a string.
4+
* Converts an object to a string.
55
*
6-
* Null object are converted to an empty string.
6+
* Null objects are converted to an empty string.
77
*
88
*
99
* Usage:

lib/formatter/uppercase.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
part of angular.formatter_internal;
22

33
/**
4-
* Converts string to uppercase.
4+
* Converts a string to uppercase.
55
*
66
* Usage:
77
*

0 commit comments

Comments
 (0)