From a5712b61115c1ca3ce3ff6dcc8a02101df5d99af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionic=C4=83=20Biz=C4=83u?= Date: Mon, 13 Jul 2015 09:08:22 +0300 Subject: [PATCH] JSDoc comments --- lib/index.js | 70 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 62 insertions(+), 8 deletions(-) diff --git a/lib/index.js b/lib/index.js index bcfeb85..536c97a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -24,8 +24,15 @@ const DATE_FORMAT = "MMM D, YYYY" } ; +/** + * GitStats + * + * @name GitStats + * @function + * @param {String} dataPath Path to the data file. + * @return {GitStats} The `GitStats` instance. + */ function GitStats(dataPath) { - var self = this; this.path = Abs(Deffy(dataPath, DEFAULT_STORE)); } @@ -42,7 +49,7 @@ function GitStats(dataPath) { * - `hash` (String): The commit hash. * * @param {Function} callback The callback function. - * @return {GitStats} The `GitStats` object. + * @return {GitStats} The `GitStats` instance. */ GitStats.prototype.record = function (data, callback) { @@ -66,6 +73,8 @@ GitStats.prototype.record = function (data, callback) { return GitStats; } + // This is not used, but remains here just in case we need + // it in the future if (typeof data.url !== "string" || !data.url) { delete data.url; } @@ -93,7 +102,7 @@ GitStats.prototype.record = function (data, callback) { * @name get * @function * @param {Function} callback The callback function. - * @return {GitStats} The `GitStats` object. + * @return {GitStats} The `GitStats` instance. */ GitStats.prototype.get = function (callback) { var self = this; @@ -119,7 +128,7 @@ GitStats.prototype.get = function (callback) { * @function * @param {Object} stats The stats to be saved. * @param {Function} callback The callback function. - * @return {GitStats} The `GitStats` object. + * @return {GitStats} The `GitStats` instance. */ GitStats.prototype.save = function (stats, callback) { WriteJson(this.path, stats, callback); @@ -139,7 +148,7 @@ GitStats.prototype.save = function (stats, callback) { * - `format` (String): The format of the date (default: `"MMM D, YYYY"`). * * @param {Function} callback The callback function called with the current day formatted (type: string) and the `Moment` date object. - * @return {GitStats} The `GitStats` object. + * @return {GitStats} The `GitStats` instance. */ GitStats.prototype.iterateDays = function (data, callback) { @@ -177,7 +186,7 @@ GitStats.prototype.iterateDays = function (data, callback) { * @function * @param {Object} data The object passed to the `iterateDays` method. * @param {Function} callback The callback function. - * @return {GitStats} The `GitStats` object. + * @return {GitStats} The `GitStats` instance. */ GitStats.prototype.graph = function (data, callback) { @@ -219,7 +228,7 @@ GitStats.prototype.graph = function (data, callback) { * @function * @param {Object} data The object passed to the `graph` method. * @param {Function} callback The callback function. - * @return {GitStats} The `GitStats` object. + * @return {GitStats} The `GitStats` instance. */ GitStats.prototype.calendar = function (data, callback) { @@ -275,7 +284,7 @@ GitStats.prototype.calendar = function (data, callback) { * @function * @param {Object} data The object passed to the `calendar` method. * @param {Function} callback The callback function. - * @return {GitStats} The `GitStats` object. + * @return {GitStats} The `GitStats` instance. */ GitStats.prototype.ansiCalendar = function (data, callback) { @@ -306,6 +315,19 @@ GitStats.prototype.ansiCalendar = function (data, callback) { return self; }; +/** + * authors + * Creates an array with the authors of a git repository. + * + * @name authors + * @function + * @param {String|Object} options The repo path or an object containing the following fields: + * + * - `repo` (String): The repository path. + * + * @param {Function} callback The callback function. + * @return {GitStats} The `GitStats` instance. + */ GitStats.prototype.authors = function (options, callback) { var repo = new Gry(options.repo); repo.exec("shortlog -s -n --all", function (err, stdout) { @@ -325,7 +347,23 @@ GitStats.prototype.authors = function (options, callback) { return this; }; +/** + * authorsPie + * Creates the authors pie. + * + * @name authorsPie + * @function + * @param {String|Object} options The repo path or an object containing the following fields: + * + * - `repo` (String): The repository path. + * - `radius` (Number): The pie radius. + * - `no_ansi` (Boolean): If `true`, the pie will not contain ansi characters. + * + * @param {Function} callback The callback function. + * @return {GitStats} The `GitStats` instance. + */ GitStats.prototype.authorsPie = function (options, callback) { + if (typeof options === "string") { options = { repo: options @@ -371,6 +409,22 @@ GitStats.prototype.authorsPie = function (options, callback) { return self; }; +/** + * globalActivity + * Creates the global contributions calendar (all commits made by all committers). + * + * @name globalActivity + * @function + * @param {String|Object} options The repo path or an object containing the following fields: + * + * - `repo` (String): The repository path. + * - `start` (String): The start date. + * - `end` (String): The end date. + * - `theme` (String|Object): The calendar theme. + * + * @param {Function} callback The callback function. + * @return {GitStats} The `GitStats` instance. + */ GitStats.prototype.globalActivity = function (options, callback) { if (typeof options === "string") {