Permalink
Browse files

Update doc style to use dox instead of ndoc.

  • Loading branch information...
1 parent aa3c39c commit 13957ea24b00ad9a04da77eb39ae495551ccfcab @cliffano committed Jul 28, 2012
Showing with 61 additions and 75 deletions.
  1. +1 −3 lib/cli.js
  2. +10 −12 lib/datagen.js
  3. +36 −45 lib/functions.js
  4. +14 −15 lib/worker.js
View
@@ -5,10 +5,8 @@ var _ = require('underscore'),
datagen = require('./datagen');
/**
- * cli#exec
- *
* Execute datagen using header, segment, and footer files in the current directory.
- **/
+ */
function exec() {
function _init() {
View
@@ -6,30 +6,28 @@ var _ = require('underscore'),
/**
* class DataGen
- **/
+ */
function DataGen() {
}
/**
- * DataGen#init(cb)
- * - cb (Function): standard cb(err, result) callback
- *
* Create example header, segment, footer template files in current directory.
- **/
+ *
+ * @param {Function} cb: standard cb(err, result) callback
+ */
DataGen.prototype.init = function (cb) {
console.log('Creating example template files: header, segment, footer');
ncp.ncp(p.join(__dirname, '../examples'), '.', cb);
};
/**
- * DataGen#generate(genId, numSegments, numWorkers, outFile)
- * - genId (Number): an ID unique to the current data generation, used by all worker processes
- * - numSegments (Number): how many segments in a data file
- * - numWorkers (Number): how many worker processes to spawn, each worker creates a data file
- * - outFile (String): the data file name, to be postfixed with worker ID
- *
* Spawn worker processes which will then generate the data file.
- **/
+ *
+ * @param {Number} genId: an ID unique to the current data generation, used by all worker processes
+ * @param {Number} numSegments: how many segments in a data file
+ * @param {Number} numWorkers: how many worker processes to spawn, each worker creates a data file
+ * @param {String} outFile: the data file name, to be postfixed with worker ID
+ */
DataGen.prototype.generate = function (genId, numSegments, numWorkers, outFile) {
genId = genId || process.pid.toString();
View
@@ -4,13 +4,12 @@ var dateFormat = require('dateformat'),
ns = new nonsense();
/**
- * functions#integer
- * - min (Number): minimum integer
- * - max (Number): maximum integer
- * - cb (Function): jazz cb(data) callback
- *
* Template function to generate a random integer.
- **/
+ *
+ * @param {Number} min: minimum integer
+ * @param {Number} max: maximum integer
+ * @param {Function} cb: jazz cb(data) callback
+ */
function integer(min, max, cb) {
var value;
// template: {integer(min, max)}
@@ -25,13 +24,12 @@ function integer(min, max, cb) {
}
/**
- * functions#float
- * - min (Number): minimum float
- * - max (Number): maximum float
- * - cb (Function): jazz cb(data) callback
- *
* Template function to generate a random float.
- **/
+ *
+ * @param {Number} min: minimum float
+ * @param {Number} max: maximum float
+ * @param {Function} cb: jazz cb(data) callback
+ */
function float(min, max, cb) {
var value;
// template: {float(min, max)}
@@ -46,14 +44,13 @@ function float(min, max, cb) {
}
/**
- * functions#date
- * - format (String): date format (felixge/node-dateformat)
- * - min (Number): minimum year
- * - max (Number): maximum year
- * - cb (Function): jazz cb(data) callback
- *
* Template function to generate a random date.
- **/
+ *
+ * @param {String} format: date format (felixge/node-dateformat)
+ * @param {Number} min: minimum year
+ * @param {Number} max: maximum year
+ * @param {Function} cb: jazz cb(data) callback
+ */
function date(format, min, max, cb) {
function _timestamp(year) {
@@ -83,25 +80,23 @@ function date(format, min, max, cb) {
}
/**
- * functions#select
- * - cb (Function): jazz cb(data) callback
- *
* Template function to select an item out of the arguments.
* Last argument must be the callback.
- **/
+ *
+ * @param {Function} cb: jazz cb(data) callback
+ */
function select() {
// template: {select(arg1, arg2, ..., argN)}
var args = Array.prototype.slice.call(arguments);
args[args.length - 1](ns.pick(args.slice(0, args.length - 1)));
}
/**
- * functions#word
- * - num (Number): how many random words to generate
- * - cb (Function): jazz cb(data) callback
- *
* Template function to generate random word(s) from Lorem Ipsum.
- **/
+ *
+ * @param {Number} num: how many random words to generate
+ * @param {Function} cb: jazz cb(data) callback
+ */
function word(num, cb) {
var value;
// template: {word(num)}
@@ -116,42 +111,38 @@ function word(num, cb) {
}
/**
- * functions#firstName
- * - cb (Function): jazz cb(data) callback
- *
* Template function to generate a random first name.
- **/
+ *
+ * @param {Function} cb: jazz cb(data) callback
+ */
function firstName(cb) {
cb(ns.firstName());
}
/**
- * functions#lastName
- * - cb (Function): jazz cb(data) callback
- *
* Template function to generate a random last name.
- **/
+ *
+ * @param {Function} cb: jazz cb(data) callback
+ */
function lastName(cb) {
cb(ns.lastName());
}
/**
- * functions#email
- * - cb (Function): jazz cb(data) callback
- *
* Template function to generate a random email.
- **/
+ *
+ * @param {Function} cb: jazz cb(data) callback
+ */
function email(cb) {
cb(faker.Internet.email());
}
/**
- * functions#phone
- * - format (String): phone number format, e.g. #### #### will generate 8 digit numbers separated with a space
- * - cb (Function): jazz cb(data) callback
- *
* Template function to generate a random phone.
- **/
+ *
+ * @param {String} format: phone number format, e.g. #### #### will generate 8 digit numbers separated with a space
+ * @param {Function} cb: jazz cb(data) callback
+ */
function phone(format, cb) {
// template: {phone(format)}
if (format && cb) {
View
@@ -4,24 +4,24 @@ var bag = require('bagofholding'),
/**
* class Worker
- * - workerId (Number): an ID unique to this worker
- **/
+ *
+ * @param {Number} workerId: an ID unique to this worker
+ */
function Worker(workerId) {
this.workerId = workerId;
}
/**
- * Worker#write(templates, genId, numSegments, outFile, cb)
- * - templates (Object): data file templates in the format of { header: '', segment: '', footer: '' }
- * - genId (Number): an ID unique to the current data generation, used by all worker processes
- * - numSegments (Number): how many segments in a data file
- * - outFile (String): the data file name, to be postfixed with worker ID
- * - cb (Function): standard cb(err, result) callback
- *
* Write a data file consisting of header, segment x numSegments, and footer templates.
* File is being streamed so it can handle large content.
* Thanks to Max Ogden's fs stream backpressure example https://gist.github.com/2516455
- **/
+ *
+ * @param {Object} templates: data file templates in the format of { header: '', segment: '', footer: '' }
+ * @param {Number} genId: an ID unique to the current data generation, used by all worker processes
+ * @param {Number} numSegments: how many segments in a data file
+ * @param {String} outFile: the data file name, to be postfixed with worker ID
+ * @param {Function} cb: standard cb(err, result) callback
+ */
Worker.prototype.write = function (templates, genId, numSegments, outFile, cb) {
var stream = fs.createWriteStream(outFile + this.workerId, { flags: 'w', encoding: 'utf-8' }),
@@ -61,12 +61,11 @@ Worker.prototype.write = function (templates, genId, numSegments, outFile, cb) {
module.exports = Worker;
/**
- * process#on(message, cb)
- * - message (Object): message object from the master process
- * - cb (Function): callback function
- *
* Create a worker and tell it to write a data file.
- **/
+ *
+ * @param {Object} message: message object from the master process
+ * @param {Function} cb: callback function
+ */
process.on('message', function (message) {
console.log('Starting worker ' + message.workerId);
new Worker(message.workerId).write(

0 comments on commit 13957ea

Please sign in to comment.