From 695d74d7c515526969ac4401cbf69520abc81234 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 29 May 2016 16:06:02 -0700 Subject: [PATCH] Add jsdocs to fp build modules. --- lib/fp/build-doc.js | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/lib/fp/build-doc.js b/lib/fp/build-doc.js index 02800bcfd..302d2462e 100644 --- a/lib/fp/build-doc.js +++ b/lib/fp/build-doc.js @@ -18,16 +18,29 @@ var templateData = { 'toFuncList': toFuncList }; -function toArgOrder(array) { +/** + * Converts arranged argument `indexes` into a named argument string + * representation of their order. + * + * @param {number[]} indexes The arranged argument indexes. + * @returns {string} Returns the named argument string. + */ +function toArgOrder(indexes) { var reordered = []; - _.each(array, function(newIndex, index) { + _.each(indexes, function(newIndex, index) { reordered[newIndex] = argNames[index]; }); return '`(' + reordered.join(', ') + ')`'; } -function toFuncList(array) { - var chunks = _.chunk(array.slice().sort(), 5), +/** + * Converts `funcNames` into a backticked chunked list string representation. + * + * @param {string[]} funcNames The function names. + * @returns {string} Returns the function list string. + */ +function toFuncList(funcNames) { + var chunks = _.chunk(funcNames.slice().sort(), 5), lastChunk = _.last(chunks), last = lastChunk ? lastChunk.pop() : undefined; @@ -51,12 +64,22 @@ function toFuncList(array) { /*----------------------------------------------------------------------------*/ +/** + * A no-frills callback that throws any error it receives. + * + * @param {Object} [error] The error object. + */ function onComplete(error) { if (error) { throw error; } } +/** + * Creates the FP-Guide wiki at the `target` path. + * + * @param {string} target The output file path. + */ function build(target) { target = path.resolve(target); fs.writeFile(target, template.wiki(templateData), onComplete);