Update fp doc generation.

This commit is contained in:
John-David Dalton
2016-02-14 20:04:35 -08:00
parent 19613be861
commit cf1a4f893f
3 changed files with 104 additions and 3 deletions

View File

@@ -1,9 +1,45 @@
'use strict';
var _ = require('lodash'),
fs = require('fs-extra'),
path = require('path'),
util = require('../common/util');
var basePath = path.join(__dirname, '..', '..'),
docPath = path.join(basePath, 'doc'),
readmePath = path.join(docPath, 'FP-Guide.md');
var mapping = require('../../fp/_mapping'),
templatePath = path.join(__dirname, 'template/doc'),
template = util.globTemplate(path.join(templatePath, '*.jst'));
var templateData = {
'mapping': mapping,
'toFuncList': toFuncList
};
function toFuncList(array) {
var chunks = _.chunk(array.slice().sort(), 5),
lastChunk = _.last(chunks),
last = lastChunk ? lastChunk.pop() : undefined;
var result = '`' + _.map(chunks, function(chunk) {
return chunk.join('`, `') + '`';
}).join(',\n`');
return result + (last == null ? '' : (', & `' + last + '`'));
}
/*----------------------------------------------------------------------------*/
function build(type) {
function onComplete(error) {
if (error) {
throw error;
}
}
build(_.last(process.argv));
function build() {
fs.writeFile(readmePath, template.wiki(templateData), onComplete);
}
build();