-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
78 lines (56 loc) · 1.89 KB
/
index.js
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* rb-assemble-docu-generator
*/
'use strict';
const kss = require('kss');
const _ = require('lodash-node');
const inflection = require('inflection');
const matter = require('gray-matter');
const promise = require('bluebird');
const fs = promise.promisifyAll(require('fs-extra'));
function livingStyleguide(params, next) {
var kssData;
const grunt = params.grunt;
const assemble = params.assemble;
const kssOptions = assemble.options.kssnode;
let parsedPage = fs.readFileSync(kssOptions.page, 'utf8');
fs.readFileAsync(kssOptions.page, 'utf8')
.then(function(data) {
console.log(data);
});
//Check if options.src is an directory
if(!fs.lstatSync(kssOptions.src).isDirectory()) {
return next(new Error('"' + kssOptions.src + '" is not a directory'));
}
//kss.traverse(kssOptions.src, {mask: kssOptions.mask || '.css'}, (err, kssData) => {
// getRootSections(kssData);
//
// return next();
//});
//Gather all of the sections first indexes in case they don't have a main element.
var getRootSections = (kssData) => {
let sections = kssData.section() || {};
let rootSections = [];
if(!sections.length) {
return next(new Error('No KSS documentation is found in source files.'));
}
sections.forEach((section, i) => {
var rootSection = section.reference().match(/[0-9]*[a-zA-z]*\.?/)[0].replace('.', '');
//Check if rootSection already exist
if(!~rootSections.indexOf(rootSection)) {
rootSections.push(rootSection);
}
rootSections.sort();
});
createNewData(rootSections, kssData);
};
var createNewData = (rootSections, kssData) => {
rootSections.forEach((section, i) => {
var sectionRoot = kssData.section(section);
//var pageContext = _.clone(parsedPage.data, true);
var assembleCollections = assemble.options.collections;
var childSections = kssData.section(section + '.*');
});
};
}
module.exports = exports = livingStyleguide;