all files / arrow-docgen/lib/ blocks.js

96% Statements 24/25
75% Branches 9/12
100% Functions 3/3
96% Lines 24/25
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47                                             
// jscs:disable jsDoc
 
var _ = require('lodash'),
	util = require('arrow-util').content;
 
function generate(object, baseurl, adminurl, context) {
	var pages = [];
 
	_.keys(object.blocks).forEach(function (name) {
		var page = {
				url: util.makeAnchor(name),
				title: name
			},
			markdown = [];
		var block = object.blocks[name];
		if (block.documented !== undefined && !block.documented) {
			return;
		}
		markdown.push('# ' + name + '\n');
		markdown.push(block.description || '');
 
		var apis = context.blocks[name];
		Eif (apis) {
			markdown.push('### APIs using ' + name + ' block');
			markdown.push('');
			apis.forEach(function (apiobj) {
				var api = apiobj.api,
					group = apiobj.name;
				Iif (apiobj.documented !== undefined && !apiobj.documented) {
					return;
				}
				markdown.push('- [' + group + ' ⇢ ' + api + '](docs.html?apis/' + util.makeAnchor(group) + '.html)');
			});
			markdown.push('');
		}
 
		markdown.push('');
 
		page.markdown = markdown.join('\n');
		pages.push(page);
	});
 
	return pages;
}
 
exports.generate = generate;