You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

26 lines
794 B

'use strict';
const fs = require('fs');
const R = require('ramda');
const utils = require('./utils');
const isMeta = R.complement(R.propEq('type', 'hr'));
const isDescription = R.complement(R.propEq('children', 'API'));
module.exports = function buildDocsList(indexes, outputPath) {
const indexesList = R.map((fileName) => {
const fileContent = utils.parseFileContent(fileName);
const meta = utils.parseMeta(fileContent);
const description = R.tail(R.dropWhile(
isMeta,
R.takeWhile(isDescription, fileContent)
));
const api = R.dropWhile(isDescription, fileContent);
return { meta, description, api };
}, indexes);
const content = 'module.exports = ' +
JSON.stringify(indexesList, null, 2) + ';';
fs.writeFile(outputPath, content);
};