Permalink
Browse files

Update doc style to use dox instead of ndoc.

  • Loading branch information...
1 parent a49163e commit 28b2bb31b72dadad6bd297731fa402cf0abd6b3d @cliffano committed Jul 28, 2012
Showing with 48 additions and 55 deletions.
  1. +1 −3 lib/cli.js
  2. +10 −12 lib/couchtato.js
  3. +16 −17 lib/db.js
  4. +21 −23 lib/util.js
View
@@ -4,10 +4,8 @@ var _ = require('underscore'),
p = require('path');
/**
- * cli#exec
- *
* Execute couchtato.
- **/
+ */
function exec() {
function _config() {
View
@@ -6,30 +6,28 @@ var _ = require('underscore'),
/**
* class Couchtato
- **/
+ */
function Couchtato() {
}
/**
- * Couchtato#config(cb)
- * - cb (Function): standard cb(err, result) callback
- *
* Create a sample couchtato.js configuration file in current directory.
- **/
+ *
+ * @param {Function} cb: standard cb(err, result) callback
+ */
Couchtato.prototype.config = function (cb) {
console.log('Creating sample configuration file: couchtato.js');
fsx.copy(p.join(__dirname, '../examples/couchtato.js'), 'couchtato.js', cb);
};
/**
- * Couchtato#iterate(tasks, url, opts, cb)
- * - tasks (Object): task functions to be applied to each document, the key is a name, the value is a function with (util, doc) signature
- * - url (String): CouchDB database URL in format http://user:pass@host:port/db
- * - opts (Object): database options describing how many and how often the documents will be retrieved
- * - cb (Function): standard cb(err, result) callback
- *
* Iterate documents in the database and apply task functions to each document.
- **/
+ *
+ * @param {Object} tasks: task functions to be applied to each document, the key is a name, the value is a function with (util, doc) signature
+ * @param {String} url: CouchDB database URL in format http://user:pass@host:port/db
+ * @param {Object} opts: database options describing how many and how often the documents will be retrieved
+ * @param {Function} cb: standard cb(err, result) callback
+ */
Couchtato.prototype.iterate = function (tasks, url, opts, cb) {
opts.batchSize = opts.batchSize || 1000;
View
@@ -5,8 +5,9 @@ var _ = require('underscore'),
/**
* class Db
- * - _url (String): CouchDB URL in format http(s)://user:pass@host:port/db
- **/
+ *
+ * @param {String} _url: CouchDB URL in format http(s)://user:pass@host:port/db
+ */
function Db(_url) {
var dbName = url.parse(_url).pathname,
@@ -17,16 +18,15 @@ function Db(_url) {
}
/**
- * Db#paginate
- * - interval (Number): interval between page retrievals, in milliseconds
- * - startKey (String): ID of the first document to retrieve, null indicates the first document in the database
- * - endKey (String): ID of the last document to retrieve
- * - pageCb (Function): a callback function to process documents per page retrieval
- * - cb (Function): standard cb(err, result) callback
- *
* Retrieve documents in CouchDB database, page by page.
* This implements linked list pagination - http://guide.couchdb.org/draft/recipes.html#fast .
- **/
+ *
+ * @param {Number} interval: interval between page retrievals, in milliseconds
+ * @param {String} startKey: ID of the first document to retrieve, null indicates the first document in the database
+ * @param {String} endKey: ID of the last document to retrieve
+ * @param {Function} pageCb: a callback function to process documents per page retrieval
+ * @param {Function} cb: standard cb(err, result) callback
+ */
Db.prototype.paginate = function (interval, startKey, endKey, pageSize, pageCb, cb) {
var done = false,
@@ -79,11 +79,10 @@ Db.prototype.paginate = function (interval, startKey, endKey, pageSize, pageCb,
};
/**
- * Db#update
- * - docs (Array): documents to be bulk updated
- *
* Bulk update an array of documents.
- **/
+ *
+ * @param {Array} docs: documents to be bulk updated
+ */
Db.prototype.update = function (docs, cb) {
this.inProgress += 1;
@@ -96,10 +95,10 @@ Db.prototype.update = function (docs, cb) {
};
/**
- * Db#done -> Boolean
+ * Check if there's any database operation (documents save/remove) in progress.
*
- * True if there's no more document in queue waiting to be updated. False otherwise.
- **/
+ * @return {Boolean} true if there's no database operation in progress, false otherwise.
+ */
Db.prototype.done = function () {
return this.inProgress === 0;
};
View
@@ -2,9 +2,10 @@ var log4js = require('log4js');
/**
* class Util
- * - stat (Object): initial stat, used to initialise reportable page and document counts to zero
- * - queue (Array): an array of documents waiting to be updated in CouchDB
- **/
+ *
+ * @param {Object} stat: initial stat, used to initialise reportable page and document counts to zero
+ * @param {Array} queue: an array of documents waiting to be updated in CouchDB
+ */
function Util(stat, queue) {
this.stat = stat || {};
this.queue = queue || [];
@@ -16,13 +17,12 @@ function Util(stat, queue) {
}
/**
- * Util#increment(key, increment)
- * - key (String): stat key
- * - increment (Number): increment value
- *
* Increment stat count for existing key.
* For new key, stat count will be set to increment value.
- **/
+ *
+ * @param {String} key: stat key
+ * @param {Number} increment: increment value
+ */
Util.prototype.increment = function (key, increment) {
if (this.stat[key]) {
this.stat[key] += increment;
@@ -32,32 +32,29 @@ Util.prototype.increment = function (key, increment) {
};
/**
- * Util#count(key)
- * - key (String): stat key
- *
* Increment stat count by 1.
- **/
+ *
+ * @param {String} key: stat key
+ */
Util.prototype.count = function (key) {
this.increment(key, 1);
};
/**
- * Util#save(doc)
- * - doc (Object): CouchDB document
- *
* Queue document for saving, increment save counter.
- **/
+ *
+ * @param {Object} doc: CouchDB document
+ */
Util.prototype.save = function (doc) {
this.count('_couchtato_save');
this.queue.push(doc);
};
/**
- * Util#remove(doc)
- * - doc (Object): CouchDB document
- *
* Mark and queue document for deletion, increment delete counter.
- **/
+ *
+ * @param {Object} doc: CouchDB document
+ */
Util.prototype.remove = function (doc) {
this.count('_couchtato_remove');
@@ -66,9 +63,10 @@ Util.prototype.remove = function (doc) {
};
/**
- * Util#log(message)
- * - message (String): the message to log
- **/
+ * Log message in file.
+ *
+ * @param {String} message: the message to log
+ */
Util.prototype.log = function (message) {
this.logger.info(message);
};

0 comments on commit 28b2bb3

Please sign in to comment.