diff options
| author | Petr Vobornik <pvoborni@redhat.com> | 2013-09-06 15:27:06 +0200 |
|---|---|---|
| committer | Petr Vobornik <pvoborni@redhat.com> | 2013-10-16 18:08:17 +0200 |
| commit | efafd7fe871bc368b91db78bb132abb027141a24 (patch) | |
| tree | f6d71bae937e31c7090828382af8b404b1ce7e1f /install/ui/src/freeipa/_base | |
| parent | 3fa304d95ec59efe0eb1cb8241d88a173802b172 (diff) | |
| download | freeipa-efafd7fe871bc368b91db78bb132abb027141a24.tar.gz freeipa-efafd7fe871bc368b91db78bb132abb027141a24.tar.xz freeipa-efafd7fe871bc368b91db78bb132abb027141a24.zip | |
Web UI source code annotation
Part of ongoing Web UI documentation effort. Source code is annotated in a way that it can be processed by documentation generator.
Diffstat (limited to 'install/ui/src/freeipa/_base')
| -rw-r--r-- | install/ui/src/freeipa/_base/Builder.js | 118 | ||||
| -rw-r--r-- | install/ui/src/freeipa/_base/Construct_registry.js | 62 | ||||
| -rw-r--r-- | install/ui/src/freeipa/_base/Phase_controller.js | 89 | ||||
| -rw-r--r-- | install/ui/src/freeipa/_base/Provider.js | 30 | ||||
| -rw-r--r-- | install/ui/src/freeipa/_base/Search_provider.js | 25 | ||||
| -rw-r--r-- | install/ui/src/freeipa/_base/Singleton_registry.js | 35 | ||||
| -rw-r--r-- | install/ui/src/freeipa/_base/Spec_mod.js | 31 | ||||
| -rw-r--r-- | install/ui/src/freeipa/_base/construct.js | 35 | ||||
| -rw-r--r-- | install/ui/src/freeipa/_base/i18n.js | 5 |
9 files changed, 279 insertions, 151 deletions
diff --git a/install/ui/src/freeipa/_base/Builder.js b/install/ui/src/freeipa/_base/Builder.js index e4669ed9e..e487aa542 100644 --- a/install/ui/src/freeipa/_base/Builder.js +++ b/install/ui/src/freeipa/_base/Builder.js @@ -28,35 +28,51 @@ define(['dojo/_base/declare', var undefined; + /** + * Builder + * + * Builds objects based on their specification. + * @class _base.Builder + */ var Builder = declare(null, { /** - * Builds objects based on specication. - * - * @class - * @name Builder - */ - - /** * Construct registry - * @property ./Construct_registry + * @property {_base.Construct_registry} */ registry: null, /** * Specification modifier + * @property {_base.Spec_mod} */ spec_mod: null, + /** + * Default factory + * @property {Function|null} + */ factory: null, + /** + * Default constructor + * @property {Function|null} + */ ctor: null, /** * Array of spec modifiers. * - * Spec modifier is a function which is called before build. - * takes params: spec, context - * returns spec + * Are applied before build on spec object. + * + * Spec modifier can be: + * + * - a function which is called before build + * - takes params: spec, context + * - returns spec + * - an object which is mixed in into spec + * - an object with properties for Spec_mod + * + * @property {Array|null} */ pre_ops: null, @@ -64,55 +80,59 @@ define(['dojo/_base/declare', * Array of object modifiers. * * Object modifier is a function which is after build. - * takes params: built object, spec, context - * returns object + * + * - takes params: built object, spec, context + * - returns object + * @property {Array|null} */ post_ops: null, /** * Controls what builder do when spec is a string. Possible values: - * * 'type' - * * 'property' - * Type: - * Spec is type. Queries registry for obtaining construction spec. * - * Property: - * Spec is a property of spec, name of property is set in - * `string_property`. This mode should be combined with default - * factory or ctor otherwise the build will fail. + * - 'type' + * - 'property' + * + * ##Type + * Spec is type. Queries registry for obtaining construction spec. + * + * ##Property + * Spec is a property of spec, name of property is set in + * `string_property`. This mode should be combined with default + * factory or ctor otherwise the build will fail. * - * @type {String} + * @property {string} */ string_mode: 'type', /** * Property name for `string_mode` == `property` - * @type {String} + * @property {string} */ string_property: '', /** * Build object based on spec. * - * @param {String|Function|Object|Array} Build spec - * @param {Object} build context - * @param {Object} overrides + * @param {string|Function|Object|Array} spec Build spec * - * String: type name, queries registry - * Function: factory or ctor - * Object: spec object - * Array: array of spec objects + * - **String**: type name, queries registry + * - **Function**: factory or ctor + * - **Object**: spec object + * - **Array**: array of spec objects * - * Build control properies of spec object: - * $ctor: Function - * $factory: Function - * $mixim_spec: Boolean - * $type: String - * $pre_ops: [] - * $post_ops: [] + * Build control properties of spec object: * - * All other properties will be passed to object construction method. + * - $ctor: Function + * - $factory: Function + * - $mixim_spec: boolean + * - $type: string + * - $pre_ops: [] + * - $post_ops: [] * + * All other properties will be passed to object construction method. + * @param {Object} context build context + * @param {Object} overrides * Builder default factory and ctor is overridden by those specified * in overrides when overrides are set. */ @@ -167,12 +187,20 @@ define(['dojo/_base/declare', return objects; }, + /** + * Build single object + * @protected + */ _build: function(spec, context) { var cs = this._get_construction_spec(spec); var obj = this._build_core(cs, context); return obj; }, + /** + * Normalizes construction specification + * @protected + */ _get_construction_spec: function(spec) { var cs = {}; @@ -235,6 +263,7 @@ define(['dojo/_base/declare', /** * Queries registry and returns copy of construction specification + * @protected */ _query_registry: function(type) { @@ -253,6 +282,7 @@ define(['dojo/_base/declare', /** * Get cs from string according to string mode + * @protected */ _get_cs_string: function(spec) { @@ -267,6 +297,10 @@ define(['dojo/_base/declare', return cs; }, + /** + * Core build method + * @protected + */ _build_core: function(construction_spec, context) { var cs = construction_spec, @@ -318,6 +352,10 @@ define(['dojo/_base/declare', return obj; }, + /** + * Apply pre_ops + * @protected + */ _run_preops: function(pre_ops, spec, context) { for (var i=0; i<pre_ops.length; i++) { var preop = pre_ops[i]; @@ -334,6 +372,10 @@ define(['dojo/_base/declare', return spec; }, + /** + * Apply post_ops + * @protected + */ _run_post_ops: function(post_ops, obj, spec, context) { for (var i=0; i<post_ops.length; i++) { var postop = post_ops[i]; diff --git a/install/ui/src/freeipa/_base/Construct_registry.js b/install/ui/src/freeipa/_base/Construct_registry.js index d9489add3..934af6ef1 100644 --- a/install/ui/src/freeipa/_base/Construct_registry.js +++ b/install/ui/src/freeipa/_base/Construct_registry.js @@ -24,12 +24,12 @@ define(['dojo/_base/declare', './construct' ], function(declare, array, lang, construct) { + /** + * Registry for storing construction specification. + * @class _base.Construct_registry + */ var Construct_registry = declare(null, { - /** - * Registry for storing construction specification. - * @class - * @name Construct_registry - */ + /** * Internal map for construction specifications. @@ -40,27 +40,25 @@ define(['dojo/_base/declare', /** * Registers construction specification * - * @param type {String|Object} type or construction spec - * @param func {Function} ctor or factory function - * @param [default_spec] {Object} default spec object for given type - * - * @returns Object + * // May be defined by single construction spec object: + * var construction_spec = { + * type: String, + * factory: Function, + * ctor: Function, + * spec: Object, + * pre_ops: [], + * post_ops: [] + * }; + * register(construction_spec); * - * Examples: + * // or by defining them separately as params: + * register(type, factory|ctor, spec); * - * May be defined by single construction spec object: - * var construction_spec = { - * type: String, - * factory: Function, - * ctor: Function, - * spec: Object, - * pre_ops: [], - * post_ops: [] - * }; - * register(construction_spec); + * @param {string|Object} type type or construction spec + * @param {Function} func ctor or factory function + * @param {Object} [default_spec] default spec object for given type * - * or by defining them separately as params: - * register(type, factory|ctor, spec); + * @returns {Object} */ register: function(type, func, default_spec) { @@ -91,9 +89,9 @@ define(['dojo/_base/declare', * Makes a copy of construct specification of original type. Extends * it with values in supplied construct specification. * - * @param {String} Original type - * @param {String} New type - * @param {Object} Construction specification + * @param {string} org_type Original type + * @param {string} new_type New type + * @param {Object} construct_spec Construction specification */ copy: function(org_type, new_type, construct_spec) { @@ -128,9 +126,9 @@ define(['dojo/_base/declare', * * When op is Object, the object gets mixed in into spec. * - * @param {type} type + * @param {string} type * @param {Function|Object} op - * @param {Boolean} move op to first position + * @param {boolean} move op to first position */ register_pre_op: function(type, op, first) { @@ -150,9 +148,9 @@ define(['dojo/_base/declare', * When op is Object, the object gets mixed in into built object. Use * with caution. * - * @param {type} type + * @param {string} type * @param {Function|Object} op - * @param {Boolean} move op to first position + * @param {boolean} first move op to first position */ register_post_op: function(type, op, first) { @@ -164,8 +162,8 @@ define(['dojo/_base/declare', /** * Gets construction specification for given type. * - * @param type {String} Type name - * @returns Object|null + * @param {string} string Type name + * @returns {Object|null} */ get: function(type) { return this._map[type] || null; diff --git a/install/ui/src/freeipa/_base/Phase_controller.js b/install/ui/src/freeipa/_base/Phase_controller.js index 095b90241..9147f201a 100644 --- a/install/ui/src/freeipa/_base/Phase_controller.js +++ b/install/ui/src/freeipa/_base/Phase_controller.js @@ -28,17 +28,66 @@ define([ '../ordered-map' ], function(lang, array, declare, Deferred, all, topic, ordered_map) { + + /** + * Phase + * + * This class does not exist, it's only for documentation purposes. + * + * @class _base.Phase_controller.phase + * @abstract + */ + /** + * Name + * @property {string} name + */ + /** + * Tasks + * @property {Array.<_base.Phase_controller.task>} tasks + */ + + /** + * Phase task + * + * This class does not exist, it's only for documentation purposes. + * + * @class _base.Phase_controller.task + * @abstract + */ + /** + * Name + * @property {number} priority + */ + /** + * Tasks + * @property {Function} handler + */ + + /** + * Phase Controller + * + * Creates synchronization points - phases - in application life cycle. + * + * Phases: + * + * - are ordered + * - consist of task + * - phase finishes when all task finishes + * - new phases can be added at runtime + * + * @class _base.Phase_controller + */ var Phase_controller = declare(null, { /** * Phases - * @type ordered_map[name, phase] + * @property {ordered_map.<string, _base.Phase_controller.phase>} */ phases: null, /** * Current phase name - * @type String + * @property {string} */ current: null, @@ -57,13 +106,14 @@ define([ /** * Runs phase - * 1) Sorts tasks of the phase based on their priority. - * 2) Runs all task sequentially. - * 3) Waits for all tasks to complete (in case of asynchronous ones) - * 4) Optionally runs next phase * - * @param {phase} Phase to runs - * @param {Boolean} Whether to run next phase when current finishes + * 1. Sorts tasks of the phase based on their priority. + * 2. Runs all task sequentially. + * 3. Waits for all tasks to complete (in case of asynchronous ones) + * 4. Optionally runs next phase + * + * @param {_base.Phase_controller.phase} phase Phase to run + * @param {boolean} next_phase Whether to run next phase when current finishes */ _run_phase: function(phase, next_phase) { @@ -104,7 +154,7 @@ define([ /** * Selects next phase and then runs it. * - * @param {Boolen} Whether to run phases continuously + * @param {boolean} continuous Whether to run phases continuously */ next_phase: function(continuous) { var phase; @@ -125,9 +175,9 @@ define([ * At phase execution, tasks are sorted by priority and executed in * that order. * - * @param {String} Name of associated phase - * @param {Function} Task handler. Should return promise if async. - * @param {Number} Priority of task. Default 10. + * @param {string} phase_name Name of associated phase + * @param {Function} handler Task handler. Should return promise if async. + * @param {number} [priority=10] Priority of task. */ add_task: function(phase_name, handler, priority) { @@ -150,12 +200,13 @@ define([ * Adds a phase * * Possible options: - * before: 'name-of-phase' - * after: 'name-of-phase' - * position: 'position for new phase' * - * @param {String} phase name - * @param {Array} tasks + * - before: 'name-of-phase' + * - after: 'name-of-phase' + * - position: 'position for new phase' + * + * @param {string} phase name + * @param {Array.<_base.Phase_controller.task>} tasks * @param {Object} options */ add_phase: function(name, tasks, options) { @@ -184,8 +235,8 @@ define([ /** * Checks if phases with given name exists * - * @param {String} name - * @return {Boolean} + * @param {string} name + * @return {boolean} */ exists: function(name) { return !!this.phases.get(name); diff --git a/install/ui/src/freeipa/_base/Provider.js b/install/ui/src/freeipa/_base/Provider.js index 8d769a2eb..b2e55aed3 100644 --- a/install/ui/src/freeipa/_base/Provider.js +++ b/install/ui/src/freeipa/_base/Provider.js @@ -30,15 +30,18 @@ * * Path is a plain object path within a source. * - * Ie. if source is { - * foo: { - * bar: { - * a: 'val' - * } - * } - * } + * // if source is + * { + * foo: { + * bar: { + * a: 'val' + * } + * } + * } * - * path: 'foo.bar.a' would return 'val' + * // path: `foo.bar.a` would return `val` + * + * @class _base.Provider * */ define(['dojo/_base/declare','dojo/_base/lang'], function(declare, lang) { @@ -48,13 +51,13 @@ define(['dojo/_base/declare','dojo/_base/lang'], function(declare, lang) { /** * Array of other providers - * @type Provider[] + * @property {_base.Provider[]} */ providers: null, /** * Source object or a function which returns source object. - * @type {Function|Object|Provider} + * @property {Function|Object|_base.Provider} */ source: null, @@ -63,19 +66,20 @@ define(['dojo/_base/declare','dojo/_base/lang'], function(declare, lang) { * * When defined, all lookups in source are based on the object * defined by this path within a source. - * @type String + * @property {string} */ path: null, /** * Value which is returned if no value nor alternative is found + * @property {Mixed} */ null_value: null, /** * Specifies which type should be returned. Limited to output of * typeof operator. - * @type String + * @property {string} */ required_type: null, @@ -153,7 +157,7 @@ define(['dojo/_base/declare','dojo/_base/lang'], function(declare, lang) { /** * Gets value. * - * @param {String|Object} Key or value + * @param {string|Object} Key or value * @param {Object} Alternate value */ get: function(key, alternate) { diff --git a/install/ui/src/freeipa/_base/Search_provider.js b/install/ui/src/freeipa/_base/Search_provider.js index fcd2b0ff7..10ef1562e 100644 --- a/install/ui/src/freeipa/_base/Search_provider.js +++ b/install/ui/src/freeipa/_base/Search_provider.js @@ -19,24 +19,30 @@ */ /** - * Search value providers. + * Search value provider * - * Serves for searching for values within a array in a source. + * Serves for searching for values within an array in a source object. + * + * Path has input formats as follows: * - * Path has following formats: * * key1:key2:key3 * * key1:key2 * * key2 * - * base_query: '%1.takes_params' - * array_attr: 'name' + * With: + * + * * base_query: `%1.takes_params` + * * array_attr: `name` + * + * Such path is translates into query: * - * It translates into following query: - * %key1.takes_params[name=%key2].$key3 + * * `%key1.takes_params[name=%key2].$key3` * * In a future we should support defining generic queries and thus not be * limited to simple search. * + * @class _base.Search_provider + * @extends _base.Provider */ define(['dojo/_base/declare','dojo/_base/lang', './Provider'], function(declare, lang, Provider) { @@ -46,6 +52,10 @@ define(['dojo/_base/declare','dojo/_base/lang', './Provider'], base_query: null, array_attr: null, + /** + * @inheritDoc + * @protected + */ _get: function(key) { var search_keys = key.substring(this._code_length); search_keys = search_keys.split(':'); @@ -80,6 +90,7 @@ define(['dojo/_base/declare','dojo/_base/lang', './Provider'], /** * Finds object with attr_name === value in array defined by key. + * @protected */ _find: function(array, attr, value, all) { diff --git a/install/ui/src/freeipa/_base/Singleton_registry.js b/install/ui/src/freeipa/_base/Singleton_registry.js index a3427d7e0..e0c55ca14 100644 --- a/install/ui/src/freeipa/_base/Singleton_registry.js +++ b/install/ui/src/freeipa/_base/Singleton_registry.js @@ -26,26 +26,25 @@ define(['dojo/_base/declare', './Construct_registry' ], function(declare, array, lang, construct, Builder, Construct_registry) { + /** + * Registry for storing singleton instances of various items based + * on their type. + * + * @class _base.Singleton_registry + */ var Singleton_registry = declare(null, { - /** - * Registry for storing singleton instances of various items based - * on their type. - * - * @class - * @name Singleton_registry - */ /** * Internal map for instances * @protected - * @type Object + * @property {Object} */ _map: {}, /** * Builder used for building new instances. Builder has to have a * Constructor registry set. - * @type Builder + * @property {_base.Builder} */ builder: null, @@ -55,8 +54,8 @@ define(['dojo/_base/declare', * * When an object is passed in, the function returns it. * - * @param type {String|Object} Type's name. Or the the object itself. - * @returns Object|null + * @param {string|Object} type Type's name. Or the the object itself. + * @return {Object|null} */ get: function(type) { @@ -79,8 +78,8 @@ define(['dojo/_base/declare', /** * Set object of given type - overwrites existing * - * @param {String} type - * @param {anything} object + * @param {string} type + * @param {Mixed} object */ set: function (type, obj) { this._map[type] = obj; @@ -89,7 +88,7 @@ define(['dojo/_base/declare', /** * Removes object of given type from registry * - * @param {String} type + * @param {string} type */ remove: function(type) { @@ -100,11 +99,11 @@ define(['dojo/_base/declare', /** * Registers construction specification * - * @param type {String|Object} type or construction spec - * @param func {Function} ctor or factory function - * @param [default_spec] {Object} default spec object for given type + * @param {string|Object} type type or construction spec + * @param {Function} func ctor or factory function + * @param {Object} [default_spec] default spec object for given type * - * @returns Object + * @return {Object} */ register: function(type, func, default_spec) { if (!lang.exists('builder.registry', this)) { diff --git a/install/ui/src/freeipa/_base/Spec_mod.js b/install/ui/src/freeipa/_base/Spec_mod.js index 60d4b9229..34f79f726 100644 --- a/install/ui/src/freeipa/_base/Spec_mod.js +++ b/install/ui/src/freeipa/_base/Spec_mod.js @@ -22,16 +22,23 @@ define(['dojo/_base/declare', 'dojo/_base/lang' ], function(declare, lang) { + /** + * Utility for common modification of specification objects + * + * @class _base.Spec_mod + */ var Spec_mod = declare(null, { /** * Modifies spec according to rules defined in diff object. * - * Diff should have following structure: { - * $add: array of add rules - * $del: array of del rules - * $set: array of set rules - * } + * Diff should have structure as follows: + * + * { + * $add: array of add rules + * $del: array of del rules + * $set: array of set rules + * } * * The order of modification is del, add, set. * @@ -54,8 +61,10 @@ define(['dojo/_base/declare', * Adds objects according to rules to array. * * A rule is a triple of path and a object and position to add: - * ['path.to.spec.array', {}, position] * + * ['path.to.spec.array', {}, position] + * @param {Object} spec + * @param {Array} rules */ add: function(spec, rules) { @@ -66,9 +75,11 @@ define(['dojo/_base/declare', * Deletes objects according to rules from an array. * * A rule is a pair of path and delete conditions: - * ['path.to.spec.array', [ { name: 'foo'}, { name: 'baz'} ]] * - * Deletes all objects with name 'baz' or 'foo'. + * ['path.to.spec.array', [ { name: 'foo'}, { name: 'baz'} ]] + * // Deletes all objects with name 'baz' or 'foo'. + * @param {Object} spec + * @param {Array} rules */ del: function(spec, rules) { @@ -77,7 +88,10 @@ define(['dojo/_base/declare', /** * A rule is a pair of path and a object to set. + * * ['path.to.spec.property', {}] + * @param {Object} spec + * @param {Array} rules */ set: function(spec, rules) { @@ -86,6 +100,7 @@ define(['dojo/_base/declare', /** * Removes all rule props + * @param {Object} diff */ del_rules: function(diff) { delete diff.$add; diff --git a/install/ui/src/freeipa/_base/construct.js b/install/ui/src/freeipa/_base/construct.js index 960596da2..ce675e588 100644 --- a/install/ui/src/freeipa/_base/construct.js +++ b/install/ui/src/freeipa/_base/construct.js @@ -23,14 +23,17 @@ define(['dojo/_base/declare', 'dojo/_base/lang' ], function(declare, array, lang) { + /** + * Helper module + * @class _base.construct + * @singleton + */ var construct = { - /** - * Helper modules - */ /** - * Checks if supplied object is a construtor function. - * It can recognize only classes declared by ''dojo/_base/declare''. + * Checks if supplied object is a constructor function. + * It can recognize only classes declared by `dojo/_base/declare`. + * @param {Object} obj */ is_ctor: function(obj) { @@ -38,13 +41,14 @@ define(['dojo/_base/declare', }, /** - * Finds out if object is a spec object. + * Finds out if object is a spec object. * - * Object is not a spec object when any of following applies: - * * has __fw_obj === true - * * has isInstanceOf function - basically tells if it's a instance of - * dojo-based class + * Object is not a spec object when any of following applies: * + * - has `__fw_obj === true` + * - has `isInstanceOf` function - basically tells if it's a instance of + * dojo-based class + * @param {Object} obj */ is_spec: function(obj) { var ret = false; @@ -56,13 +60,14 @@ define(['dojo/_base/declare', }, /** - * Deep clone. - * - does not clone framework objects - * - fails on cyclic non-framework objects + * Deep clone + * + * - does not clone framework objects + * - fails on cyclic non-framework objects * - * based on dojo/_base/lang.clone + * based on `dojo/_base/lang.clone` * - * @param {anything} object to clone + * @param {Mixed} src object to clone */ clone: function(src) { diff --git a/install/ui/src/freeipa/_base/i18n.js b/install/ui/src/freeipa/_base/i18n.js index 970705bba..ae9b40bca 100644 --- a/install/ui/src/freeipa/_base/i18n.js +++ b/install/ui/src/freeipa/_base/i18n.js @@ -21,11 +21,14 @@ /** * Gets translated message. * -* If a message starts with @i18n: it tries to get the message from +* If a message starts with `@i18n`: it tries to get the message from * message object. If it doesn't contain a string with * the key it returns alternate string. * * It all other cases the message itself or empty string is returned. +* @class _base.i18n +* @extends _base.Provider +* @singleton */ define(['dojo/_base/lang', './Provider'], function(lang, Provider) { |
