delebash
4/17/2015 - 4:20 AM

outputs kss to json string

outputs kss to json string

//install kss and  fs-extra: npm install kss fs-extra

var kss = require('kss'),
    options = {
        markdown: false
    };
var fs = require('fs-extra');

var file = './docs/kss.json';

kss.traverse('.', options, function (err, styleguide) {
    if (err) throw err;

    var mySections = styleguide.section();
    var myJsonSections = []
    for (var i = 0, tot = mySections.length; i < tot; i++) {
        myJsonSections.push(mySections[i].JSON());
    }

    fs.outputJson(file, myJsonSections, function (err) {
        console.log(err) // => null
    })
});