forked from okami101/vuetify-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docgen.js
35 lines (30 loc) · 900 Bytes
/
docgen.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
const glob = require("globby");
const { parse } = require("vue-docgen-api");
let getDocComponents = (relative = ".") => {
return Promise.all(
glob
.sync(`${relative}/src/components/(layout|ui)/**/[A-Z]*.vue`)
.map(async (path) => {
let doc = await parse(path);
doc.mixins = [];
/**
* Move props and events to proper mixins.
*/
["props", "events"].forEach((type) => {
if (doc[type]) {
doc[type].forEach((p) => {
if (p.mixin && !doc.mixins.includes(p.mixin.name)) {
doc.mixins.push(p.mixin.name);
}
});
}
});
return doc;
})
);
};
let getDocMixins = (relative = ".") =>
Promise.all(
glob.sync(`${relative}/src/mixins/**/*.js`).map((path) => parse(path))
);
module.exports = { getDocComponents, getDocMixins };