forked from okami101/vuetify-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeta.js
84 lines (75 loc) · 2.08 KB
/
meta.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
const path = require("path");
const fs = require("fs");
const rimraf = require("rimraf");
const mkdirp = require("mkdirp");
const { kebabCase } = require("lodash");
const { getDocComponents } = require("./docgen");
const metaDir = path.resolve(__dirname, "dist/json");
rimraf.sync(metaDir);
mkdirp.sync(metaDir);
let tagsJson = {};
let attributesJson = {};
let webTypesJson = [];
const writeJsonFile = (dir, file, json) => {
fs.writeFileSync(
path.resolve(dir, file),
JSON.stringify(json, null, 2) + "\n"
);
};
getDocComponents().then((docs) => {
docs.forEach((doc) => {
let tag = kebabCase(doc.displayName);
/**
* Generate Vetur meta
*/
tagsJson[`va-${tag}`] = {
description: doc.description,
attributes: (doc.props || []).map((p) => kebabCase(p.name)),
};
(doc.props || []).forEach((p) => {
attributesJson[`va-${tag}/${kebabCase(p.name)}`] = {
description: p.description,
type: p.type.name,
};
});
/**
* Generate Jetbrains meta
*/
webTypesJson.push({
name: `Va${doc.displayName}`,
description: doc.description,
attributes: (doc.props || []).map((p) => {
return {
name: p.name,
value: {
kind: "expression",
type: p.type.name,
},
...(p.type.name === "boolean" &&
!p.defaultValue && { default: "false" }),
...(p.type.name === "boolean" && { type: p.type.name }),
description: p.description,
};
}),
});
/**
* Write JSON files
*/
writeJsonFile(metaDir, "tags.json", tagsJson);
writeJsonFile(metaDir, "attributes.json", attributesJson);
writeJsonFile(metaDir, "web-types.json", {
$schema:
"https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
framework: "vue",
name: "vuetify-admin",
version: "0.1.0",
contributions: {
html: {
"types-syntax": "typescript",
"description-markup": "markdown",
tags: webTypesJson,
},
},
});
});
});