Skip to content

Commit

Permalink
Create new gulp tasks using latest gulp APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
Marak committed Aug 22, 2020
1 parent 6735a0c commit 22f8dba
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
17 changes: 17 additions & 0 deletions build/gulp-tasks/jsdoc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
this task will generate the jsdoc based HTML documentation found in the /doc/ folder
*/

const { src, dest } = require('gulp');
const mustache = require('gulp-mustache');
const rename = require('gulp-rename');
const jsdoc = require('gulp-jsdoc3');

const config = require('../../conf.json');

module.exports = function jdsoc (cb) {
src(['./README.md', './lib/*.js'], { read: false })
.pipe(jsdoc(config, cb));
};
46 changes: 46 additions & 0 deletions build/gulp-tasks/readme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
this task will generate the Readme.md file found in the project root
*/

const { src, dest } = require('gulp');
const mustache = require('gulp-mustache');
const rename = require('gulp-rename');

module.exports = function readme (cb) {
var API = '', LOCALES = '';
var faker = require('../../index');

// generate locale list
for (var locale in faker.locales) {
LOCALES += ' * ' + locale + '\n';
}

var keys = Object.keys(faker);
keys = keys.sort();

// generate nice tree of api for docs
keys.forEach(function(module){
// ignore certain properties
var ignore = ['locale', 'localeFallback', 'definitions', 'locales'];
if (ignore.indexOf(module) !== -1) {
return;
}
API += '* ' + module + '\n';
for (var method in faker[module]) {
API += ' * ' + method + '\n';
}
});

return src('build/src/docs.md')
.pipe(mustache({
'API': API,
'LOCALES': LOCALES,
'startYear': 2010,
'currentYear': new Date().getFullYear()
}))
.pipe(rename("../Readme.md"))
.pipe(dest('build/'));

};

0 comments on commit 22f8dba

Please sign in to comment.