Commit 26c8da78 authored by Tristan Cavelier's avatar Tristan Cavelier

make queries doc string fully compatible with yuidoc

parent a4f3d0d1
...@@ -15,7 +15,7 @@ var complex_queries; ...@@ -15,7 +15,7 @@ var complex_queries;
var to_export = {}, module_name = "complex_queries"; var to_export = {}, module_name = "complex_queries";
/** /**
* Add a secured (write permission denied) property to an object. * Add a secured (write permission denied) property to an object.
* @method defineProperty *
* @param {Object} object The object to fill * @param {Object} object The object to fill
* @param {String} key The object key where to store the property * @param {String} key The object key where to store the property
* @param {Any} value The value to store * @param {Any} value The value to store
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
* values. * values.
* *
* @class ComplexQuery * @class ComplexQuery
* @extends Query
* @param {Object} [spec={}] The specifications * @param {Object} [spec={}] The specifications
* @param {String} [spec.operator="AND"] The compare method to use * @param {String} [spec.operator="AND"] The compare method to use
* @param {String} spec.key The metadata key * @param {String} spec.key The metadata key
...@@ -18,18 +19,20 @@ var ComplexQuery = newClass(Query, function (spec) { ...@@ -18,18 +19,20 @@ var ComplexQuery = newClass(Query, function (spec) {
/** /**
* Logical operator to use to compare object values * Logical operator to use to compare object values
* *
* @property operator * @attribute operator
* @type String * @type String
* @default "AND" * @default "AND"
* @optional
*/ */
this.operator = spec.operator || "AND"; this.operator = spec.operator || "AND";
/** /**
* The sub Query list which are used to query an item. * The sub Query list which are used to query an item.
* *
* @property query_list * @attribute query_list
* @type Array * @type Array
* @default [] * @default []
* @optional
*/ */
this.query_list = spec.query_list || []; this.query_list = spec.query_list || [];
this.query_list = this.query_list.map(QueryFactory.create); this.query_list = this.query_list.map(QueryFactory.create);
......
/**
* Parse a text request to a json query tree
* @method parseStringToObject
* @param {String} string The string to parse
* @return {Object} The json query tree
*/
function parseStringToObject(string) { function parseStringToObject(string) {
...@@ -14,8 +14,10 @@ var Query = newClass(function (spec) { ...@@ -14,8 +14,10 @@ var Query = newClass(function (spec) {
/** /**
* The wildcard character used to extend comparison action * The wildcard character used to extend comparison action
* *
* @property wildcard_character * @attribute wildcard_character
* @type String * @type String
* @default "%"
* @optional
*/ */
this.wildcard_character = spec.wildcard_character || "%"; this.wildcard_character = spec.wildcard_character || "%";
...@@ -24,13 +26,13 @@ var Query = newClass(function (spec) { ...@@ -24,13 +26,13 @@ var Query = newClass(function (spec) {
* *
* @method exec * @method exec
* @param {Array} item_list The list of object * @param {Array} item_list The list of object
* @param {Object} [option={}] Some operation option * @param {Object} [option] Some operation option
* @param {String} [option.wildcard_character="%"] The wildcard character * @param {String} [option.wildcard_character="%"] The wildcard character
* @param {Array} [option.select_list=undefined] A object keys to retrieve * @param {Array} [option.select_list] A object keys to retrieve
* @param {Array} [option.sort_on=[]] Couples of object keys * @param {Array} [option.sort_on] Couples of object keys and "ascending"
* and "ascending" or "descending" * or "descending"
* @param {Array} [option.limit=undefined] Couple of integer, first is an * @param {Array} [option.limit] Couple of integer, first is an index and
* index and second is the length. * second is the length.
*/ */
this.exec = function (item_list, option) { this.exec = function (item_list, option) {
var i = 0; var i = 0;
...@@ -92,6 +94,7 @@ var Query = newClass(function (spec) { ...@@ -92,6 +94,7 @@ var Query = newClass(function (spec) {
* Filter a list of items, modifying them to select only wanted keys. * Filter a list of items, modifying them to select only wanted keys.
* *
* @method filterListSelect * @method filterListSelect
* @static
* @param {Array} select_option Key list to keep * @param {Array} select_option Key list to keep
* @param {Array} list The item list to filter * @param {Array} list The item list to filter
*/ */
...@@ -115,6 +118,7 @@ var Query = newClass(function (spec) { ...@@ -115,6 +118,7 @@ var Query = newClass(function (spec) {
* Sort a list of items, according to keys and directions. * Sort a list of items, according to keys and directions.
* *
* @method sortOn * @method sortOn
* @static
* @param {Array} sort_on_option List of couples [key, direction] * @param {Array} sort_on_option List of couples [key, direction]
* @param {Array} list The item list to sort * @param {Array} list The item list to sort
*/ */
...@@ -133,6 +137,7 @@ var Query = newClass(function (spec) { ...@@ -133,6 +137,7 @@ var Query = newClass(function (spec) {
* Parse a text request to a json query object tree * Parse a text request to a json query object tree
* *
* @method parseStringToObject * @method parseStringToObject
* @static
* @param {String} string The string to parse * @param {String} string The string to parse
* @return {Object} The json query tree * @return {Object} The json query tree
*/ */
......
...@@ -2,13 +2,27 @@ ...@@ -2,13 +2,27 @@
/*global _export: true, ComplexQuery: true, SimpleQuery: true, /*global _export: true, ComplexQuery: true, SimpleQuery: true,
newClass: true, Query: true */ newClass: true, Query: true */
// XXX
var query_class_dict = {}, QueryFactory; var query_class_dict = {}, QueryFactory;
/**
* Provides static methods to create Query object
*
* @class QueryFactory
*/
QueryFactory = newClass({ QueryFactory = newClass({
"secure_methods": true,
"static_methods": { "static_methods": {
// XXX
/**
* Creates Query object from a search text string or a serialized version
* of a Query.
*
* @method create
* @static
* @param {Object,String} object The search text or the serialized version
* of a Query
* @return {Query} A Query object
*/
"create": function (object) { "create": function (object) {
if (object === "") { if (object === "") {
return new Query(); return new Query();
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
* The SimpleQuery inherits from Query, and compares one metadata value * The SimpleQuery inherits from Query, and compares one metadata value
* *
* @class SimpleQuery * @class SimpleQuery
* @extends Query
* @param {Object} [spec={}] The specifications * @param {Object} [spec={}] The specifications
* @param {String} [spec.operator="="] The compare method to use * @param {String} [spec.operator="="] The compare method to use
* @param {String} spec.key The metadata key * @param {String} spec.key The metadata key
...@@ -16,16 +17,17 @@ var SimpleQuery = newClass(Query, function (spec) { ...@@ -16,16 +17,17 @@ var SimpleQuery = newClass(Query, function (spec) {
/** /**
* Operator to use to compare object values * Operator to use to compare object values
* *
* @property operator * @attribute operator
* @type String * @type String
* @default "=" * @default "="
* @optional
*/ */
this.operator = spec.operator || "="; this.operator = spec.operator || "=";
/** /**
* Key of the object which refers to the value to compare * Key of the object which refers to the value to compare
* *
* @property key * @attribute key
* @type String * @type String
*/ */
this.key = spec.key; this.key = spec.key;
...@@ -33,7 +35,7 @@ var SimpleQuery = newClass(Query, function (spec) { ...@@ -33,7 +35,7 @@ var SimpleQuery = newClass(Query, function (spec) {
/** /**
* Value is used to do the comparison with the object value * Value is used to do the comparison with the object value
* *
* @property value * @attribute value
* @type String * @type String
*/ */
this.value = spec.value; this.value = spec.value;
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
* Create a class, manage inheritance, static methods, * Create a class, manage inheritance, static methods,
* protected attributes and can hide methods or/and secure methods * protected attributes and can hide methods or/and secure methods
* *
* @method newClass
* @param {Class} Class Classes to inherit from (0..n). The last class * @param {Class} Class Classes to inherit from (0..n). The last class
* parameter will inherit from the previous one, and so on * parameter will inherit from the previous one, and so on
* @param {Object} option Class option (0..n) * @param {Object} option Class option (0..n)
...@@ -100,7 +99,7 @@ function newClass() { ...@@ -100,7 +99,7 @@ function newClass() {
/** /**
* Escapes regexp special chars from a string. * Escapes regexp special chars from a string.
* @method stringEscapeRegexpCharacters *
* @param {String} string The string to escape * @param {String} string The string to escape
* @return {String} The escaped string * @return {String} The escaped string
*/ */
...@@ -109,11 +108,10 @@ function stringEscapeRegexpCharacters(string) { ...@@ -109,11 +108,10 @@ function stringEscapeRegexpCharacters(string) {
return string.replace(/([\\\.\$\[\]\(\)\{\}\^\?\*\+\-])/g, "\\$1"); return string.replace(/([\\\.\$\[\]\(\)\{\}\^\?\*\+\-])/g, "\\$1");
} }
} }
_export("stringEscapeRegexpCharacters", stringEscapeRegexpCharacters);
/** /**
* Convert a search text to a regexp. * Convert a search text to a regexp.
* @method convertSearchTextToRegExp *
* @param {String} string The string to convert * @param {String} string The string to convert
* @param {String} [wildcard_character=undefined] The wildcard chararter * @param {String} [wildcard_character=undefined] The wildcard chararter
* @return {RegExp} The search text regexp * @return {RegExp} The search text regexp
...@@ -124,7 +122,6 @@ function convertSearchTextToRegExp(string, wildcard_character) { ...@@ -124,7 +122,6 @@ function convertSearchTextToRegExp(string, wildcard_character) {
'.*' '.*'
) + "$"); ) + "$");
} }
_export("convertSearchTextToRegExp", convertSearchTextToRegExp);
// XXX // XXX
function sortFunction(key, way) { function sortFunction(key, way) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment