3 var _ = require('lodash'),
4 fs = require('fs-extra'),
5 path = require('path');
7 var file = require('../common/file'),
8 mapping = require('../common/mapping');
10 var templatePath = path.join(__dirname, 'template/doc'),
11 template = file.globTemplate(path.join(templatePath, '*.jst'));
13 var argNames = ['a', 'b', 'c', 'd'];
17 'toArgOrder': toArgOrder,
18 'toFuncList': toFuncList
21 function toArgOrder(array) {
23 _.each(array, function(newIndex, index) {
24 reordered[newIndex] = argNames[index];
26 return '`(' + reordered.join(', ') + ')`';
29 function toFuncList(array) {
30 var chunks = _.chunk(array.slice().sort(), 5),
31 lastChunk = _.last(chunks),
32 last = lastChunk ? lastChunk.pop() : undefined;
34 chunks = _.reject(chunks, _.isEmpty);
35 lastChunk = _.last(chunks);
37 var result = '`' + _.map(chunks, function(chunk) {
38 return chunk.join('`, `') + '`';
44 if (_.size(chunks) > 1 || _.size(lastChunk) > 1) {
48 result += _.size(lastChunk) < 5 ? ' ' : '\n';
49 return result + '`' + last + '`';
52 /*----------------------------------------------------------------------------*/
54 function onComplete(error) {
60 function build(target) {
61 target = path.resolve(target);
62 fs.writeFile(target, template.wiki(templateData), onComplete);
65 build(_.last(process.argv));