-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
104 lines (96 loc) · 3.21 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
var pug = require("pug");
function generateDoc(componentSource) {
initMockupClockworkRT();
initExtensionPoints();
eval(componentSource);
preproccessExtensionPoints(extensionPoints);
return generateHTML(extensionPoints);
}
var extensionPoints;
function initExtensionPoints() {
extensionPoints = {
components: [],
collisions: [],
renderingLibraries: [],
renderingPipeline: null
};
}
var CLOCKWORKRT = {};
function initMockupClockworkRT() {
CLOCKWORKRT = {};
//List of components, only two operations are allowed: register and get
CLOCKWORKRT.components = (function () {
var list = [];
return {
register: function (x) {
//Array
if (x && x.length > 0) {
x.forEach(x => list.push(x));
x.forEach(x => extensionPoints.components.push(x));
}
//Element
if (x && x.length == undefined) {
list.push(x);
extensionPoints.components.push(x);
}
},
get: function () {
return list;
}
};
})();
//List of components, only two operations are allowed: register and get
CLOCKWORKRT.collisions = (function () {
var list = [];
return {
register: function (x) {
//Array
if (x && x.length > 0) {
x.forEach(x => list.push(x));
x.forEach(x => extensionPoints.collisions.push(x));
}
//Element
if (x && x.length == undefined) {
list.push(x);
extensionPoints.collisions.push(x);
}
},
get: function () {
return list;
}
};
})();
//List of rendering libraries, plus rendering pipeline
CLOCKWORKRT.rendering = (function () {
var renderingLibraries = {};
var renderingPipeline = ["<previousRenderingPipeline>"];
return {
register: function (name, constructor, desc) {
renderingLibraries[name] = constructor;
extensionPoints.renderingLibraries.push({ name: name, description: desc });
},
get: function (name) {
return renderingLibraries[name];
},
setPipeline: function (pipeline) {
//This pipeline is an array with all the rendering librarie that have to be used
renderingPipeline = pipeline;
extensionPoints.renderingPipeline = pipeline;
},
getPipeline: function () {
return renderingPipeline;
}
};
})();
}
function preproccessExtensionPoints(extensionPoints) {
extensionPoints.components.forEach(function (component) {
component.events = component.events.filter(function (e) { return e.description });
})
}
function generateHTML(extensionPoints) {
var path = require("path");
var template = pug.compileFile(path.join(__dirname, 'template.pug'));
return template(extensionPoints);
}
exports.generateDoc = generateDoc;