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