Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 446f6b2

Browse files
Toni Thompsonvojtajina
Toni Thompson
authored andcommitted
doc(API): various API documentation improvements
1 parent e3fad0f commit 446f6b2

File tree

3 files changed

+221
-179
lines changed

3 files changed

+221
-179
lines changed

src/Angular.js

+73-50
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ var manualUppercase = function (s) {
4444

4545

4646
// String#toLowerCase and String#toUpperCase don't produce correct results in browsers with Turkish
47-
// locale, for this reason we need to detect this case and redefine lowercase/uppercase methods with
48-
// correct but slower alternatives.
47+
// locale, for this reason we need to detect this case and redefine lowercase/uppercase methods
48+
// with correct but slower alternatives.
4949
if ('i' !== 'I'.toLowerCase()) {
5050
lowercase = manualLowercase;
5151
uppercase = manualUppercase;
@@ -118,10 +118,11 @@ var _undefined = undefined,
118118
* @function
119119
*
120120
* @description
121-
* Invokes the `iterator` function once for each item in `obj` collection. The collection can either
122-
* be an object or an array. The `iterator` function is invoked with `iterator(value, key)`, where
123-
* `value` is the value of an object property or an array element and `key` is the object property
124-
* key or array element index. Optionally, `context` can be specified for the iterator function.
121+
* Invokes the `iterator` function once for each item in `obj` collection. The collection can
122+
* either be an object or an array. The `iterator` function is invoked with `iterator(value, key)`,
123+
* where `value` is the value of an object property or an array element and `key` is the object
124+
* property key or array element index. Optionally, `context` can be specified for the iterator
125+
* function.
125126
*
126127
* Note: this function was previously known as `angular.foreach`.
127128
*
@@ -222,8 +223,8 @@ function nextUid() {
222223
* @function
223224
*
224225
* @description
225-
* Extends the destination object `dst` by copying all of the properties from the `src` object(s) to
226-
* `dst`. You can specify multiple `src` objects.
226+
* Extends the destination object `dst` by copying all of the properties from the `src` object(s)
227+
* to `dst`. You can specify multiple `src` objects.
227228
*
228229
* @param {Object} dst The destination object.
229230
* @param {...Object} src The source object(s).
@@ -428,9 +429,13 @@ function isWindow(obj) {
428429
return obj && obj.document && obj.location && obj.alert && obj.setInterval;
429430
}
430431

431-
function isBoolean(value) { return typeof value == $boolean;}
432+
function isBoolean(value) { return typeof value == $boolean; }
432433
function isTextNode(node) { return nodeName_(node) == '#text'; }
433-
function trim(value) { return isString(value) ? value.replace(/^\s*/, '').replace(/\s*$/, '') : value; }
434+
435+
function trim(value) {
436+
return isString(value) ? value.replace(/^\s*/, '').replace(/\s*$/, '') : value;
437+
}
438+
434439
function isElement(node) {
435440
return node &&
436441
(node.nodeName // we are a direct element
@@ -451,10 +456,12 @@ function makeMap(str){
451456

452457

453458
/**
454-
* HTML class which is the only class which can be used in ng:bind to inline HTML for security reasons.
459+
* HTML class which is the only class which can be used in ng:bind to inline HTML for security
460+
* reasons.
461+
*
455462
* @constructor
456463
* @param html raw (unsafe) html
457-
* @param {string=} option if set to 'usafe' then get method will return raw (unsafe/unsanitized) html
464+
* @param {string=} option If set to 'usafe', get method will return raw (unsafe/unsanitized) html
458465
*/
459466
function HTML(html, option) {
460467
this.html = html;
@@ -470,7 +477,8 @@ function HTML(html, option) {
470477
if (msie < 9) {
471478
nodeName_ = function(element) {
472479
element = element.nodeName ? element : element[0];
473-
return (element.scopeName && element.scopeName != 'HTML' ) ? uppercase(element.scopeName + ':' + element.nodeName) : element.nodeName;
480+
return (element.scopeName && element.scopeName != 'HTML')
481+
? uppercase(element.scopeName + ':' + element.nodeName) : element.nodeName;
474482
};
475483
} else {
476484
nodeName_ = function(element) {
@@ -500,26 +508,35 @@ function map(obj, iterator, context) {
500508
* @function
501509
*
502510
* @description
503-
* Determines the number of elements in an array, number of properties of an object or string
504-
* length.
511+
* Determines the number of elements in an array, the number of properties an object has, or
512+
* the length of a string.
505513
*
506-
* Note: this function is used to augment the Object type in angular expressions. See
507-
* {@link angular.Object} for more info.
514+
* Note: This function is used to augment the Object type in Angular expressions. See
515+
* {@link angular.Object} for more information about Angular arrays.
508516
*
509-
* @param {Object|Array|string} obj Object, array or string to inspect.
517+
* @param {Object|Array|string} obj Object, array, or string to inspect.
510518
* @param {boolean} [ownPropsOnly=false] Count only "own" properties in an object
511519
* @returns {number} The size of `obj` or `0` if `obj` is neither an object or an array.
512520
*
513521
* @example
514522
* <doc:example>
515523
* <doc:source>
516-
* Number of items in array: {{ [1,2].$size() }}<br/>
517-
* Number of items in object: {{ {a:1, b:2, c:3}.$size() }}<br/>
524+
* <script>
525+
* function SizeCtrl() {
526+
* this.fooStringLength = angular.Object.size('foo');
527+
* }
528+
* </script>
529+
* <div ng:controller="SizeCtrl">
530+
* Number of items in array: {{ [1,2].$size() }}<br/>
531+
* Number of items in object: {{ {a:1, b:2, c:3}.$size() }}<br/>
532+
* String length: {{fooStringLength}}
533+
* </div>
518534
* </doc:source>
519535
* <doc:scenario>
520536
* it('should print correct sizes for an array and an object', function() {
521537
* expect(binding('[1,2].$size()')).toBe('2');
522538
* expect(binding('{a:1, b:2, c:3}.$size()')).toBe('3');
539+
* expect(binding('fooStringLength')).toBe('3');
523540
* });
524541
* </doc:scenario>
525542
* </doc:example>
@@ -581,24 +598,21 @@ function isLeafNode (node) {
581598
* @function
582599
*
583600
* @description
584-
* Creates a deep copy of `source`.
601+
* Creates a deep copy of `source`, which should be an object or an array.
585602
*
586-
* If `source` is an object or an array, all of its members will be copied into the `destination`
587-
* object.
603+
* * If no destination is supplied, a copy of the object or array is created.
604+
* * If a destination is provided, all of its elements (for array) or properties (for objects)
605+
* are deleted and then all elements/properties from the source are copied to it.
606+
* * If `source` is not an object or array, `source` is returned.
588607
*
589-
* If `destination` is not provided and `source` is an object or an array, a copy is created &
590-
* returned, otherwise the `source` is returned.
608+
* Note: this function is used to augment the Object type in Angular expressions. See
609+
* {@link angular.Array} for more information about Angular arrays.
591610
*
592-
* If `destination` is provided, all of its properties will be deleted.
593-
*
594-
* Note: this function is used to augment the Object type in angular expressions. See
595-
* {@link angular.Object} for more info.
596-
*
597-
* @param {*} source The source to be used to make a copy.
598-
* Can be any type including primitives, `null` and `undefined`.
599-
* @param {(Object|Array)=} destination Optional destination into which the source is copied. If
611+
* @param {*} source The source that will be used to make a copy.
612+
* Can be any type, including primitives, `null`, and `undefined`.
613+
* @param {(Object|Array)=} destination Destination into which the source is copied. If
600614
* provided, must be of the same type as `source`.
601-
* @returns {*} The copy or updated `destination` if `destination` was specified.
615+
* @returns {*} The copy or updated `destination`, if `destination` was specified.
602616
*
603617
* @example
604618
* <doc:example>
@@ -660,7 +674,6 @@ function copy(source, destination){
660674
}
661675

662676
/**
663-
* @workInProgress
664677
* @ngdoc function
665678
* @name angular.equals
666679
* @function
@@ -675,16 +688,19 @@ function copy(source, destination){
675688
* @function
676689
*
677690
* @description
678-
* Determines if two objects or value are equivalent.
691+
* Determines if two objects or two values are equivalent. Supports value types, arrays and
692+
* objects.
679693
*
680-
* To be equivalent, they must pass `===` comparison or be of the same type and have all their
681-
* properties pass `===` comparison. During property comparision properties of `function` type and
682-
* properties with name starting with `$` are ignored.
694+
* Two objects or values are considered equivalent if at least one of the following is true:
683695
*
684-
* Supports values types, arrays and objects.
696+
* * Both objects or values pass `===` comparison.
697+
* * Both objects or values are of the same type and all of their properties pass `===` comparison.
685698
*
686-
* Note: this function is used to augment the Object type in angular expressions. See
687-
* {@link angular.Object} for more info.
699+
* During a property comparision, properties of `function` type and properties with names
700+
* that begin with `$` are ignored.
701+
*
702+
* Note: This function is used to augment the Object type in Angular expressions. See
703+
* {@link angular.Array} for more information about Angular arrays.
688704
*
689705
* @param {*} o1 Object or value to compare.
690706
* @param {*} o2 Object or value to compare.
@@ -732,7 +748,9 @@ function equals(o1, o2) {
732748
} else {
733749
keySet = {};
734750
for(key in o1) {
735-
if (key.charAt(0) !== '$' && !isFunction(o1[key]) && !equals(o1[key], o2[key])) return false;
751+
if (key.charAt(0) !== '$' && !isFunction(o1[key]) && !equals(o1[key], o2[key])) {
752+
return false;
753+
}
736754
keySet[key] = true;
737755
}
738756
for(key in o2) {
@@ -802,7 +820,9 @@ function sliceArgs(args, startIndex) {
802820
* @function
803821
*
804822
* @description
805-
* Returns a function which calls function `fn` bound to `self` (`self` becomes the `this` for `fn`).
823+
* Returns a function which calls function `fn` bound to `self`
824+
* (`self` becomes the `this` for `fn`).
825+
*
806826
* Optional `args` can be supplied which are prebound to the function, also known as
807827
* [function currying](http://en.wikipedia.org/wiki/Currying).
808828
*
@@ -826,7 +846,8 @@ function bind(self, fn) {
826846
: fn.call(self);
827847
};
828848
} else {
829-
// in IE, native methods are not functions and so they can not be bound (but they don't need to be)
849+
// in IE, native methods are not functions and so they can not be bound
850+
// (but they don't need to be)
830851
return fn;
831852
}
832853
}
@@ -928,7 +949,6 @@ function encodeUriQuery(val, pctEncodeSpaces) {
928949

929950

930951
/**
931-
* @workInProgress
932952
* @ngdoc directive
933953
* @name angular.directive.ng:autobind
934954
* @element script
@@ -938,14 +958,17 @@ function encodeUriQuery(val, pctEncodeSpaces) {
938958
* @TODO rename to ng:autobind to ng:autoboot
939959
*
940960
* @description
961+
* Technically, ng:autobind is not a directive; it is an Angular bootstrap parameter that can act
962+
* as a directive. It must exist in the script used to boot Angular and can be used only one time.
963+
* For details on bootstrapping Angular, see {@link guide/dev_guide.bootstrap Initializing Angular}
964+
* in the Angular Developer Guide.
941965
*
942-
* `ng:autobind` with no parameters tells angular to compile and manage the whole page.
966+
* `ng:autobind` with no parameters tells Angular to compile and manage the whole page.
943967
*
944-
* `ng:autobind="[root element ID]"` tells angular to compile and manage part of the docucment,
968+
* `ng:autobind="[root element ID]"` tells Angular to compile and manage part of the document,
945969
* starting at "root element ID".
946970
*
947-
* For details on bootstrapping angular, see {@link guide/dev_guide.bootstrap Initializing Angular}
948-
* in the Angular Developer Guide.
971+
949972
*/
950973
function angularInit(config, document){
951974
var autobind = config.autobind;

0 commit comments

Comments
 (0)