@@ -24,13 +24,14 @@ let directiveGroups = {}
24
24
25
25
// Base web-types object
26
26
const webTypes = {
27
-
$schema: '',
27
+
$schema: 'https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json',
28
28
framework: 'vue',
29
29
name: libraryName,
30
30
version: libraryVersion,
31
31
contributions: {
32
32
html: {
33
33
'types-syntax': 'typescript',
34
+
'description-markup': 'markdown',
34
35
// Components get placed here
35
36
tags: [],
36
37
// Directives get placed in here
@@ -115,7 +116,7 @@ const computePropDefault = ({ default: def, type }) => {
115
116
}
116
117
117
118
// Process a single component's meta and definition/class objects
118
-
const processComponentMeta = (meta, groupRef, docUrl) => {
119
+
const processComponentMeta = (meta, groupRef, groupDescription, docUrl) => {
119
120
const componentName = meta.component
120
121
121
122
// Pull information from the component definition/class
@@ -128,27 +129,23 @@ const processComponentMeta = (meta, groupRef, docUrl) => {
128
129
const $events = meta.events || []
129
130
const $slots = meta.slots || []
130
131
const $aliases = meta.aliases || []
131
-
// This doesn't exist yet (for prop descriptions, info)
132
-
// For description (and possibly more) for props docs
133
-
// source is array format, so we convert to a hash object
132
+
// Pull in any prop info from the meta (i.e. description)
134
133
const $propsExtra = (meta.props || []).reduce((obj, p) => {
135
134
if (p && p.prop) {
136
135
obj[p.prop] = p
137
136
}
138
137
return obj
139
138
}, {})
140
139
141
-
const tagName = kebabCase(componentName)
142
-
143
140
// Build the tag reference
144
141
const tag = {
145
142
name: componentName,
146
143
source: {
147
144
module: libraryName,
148
145
symbol: componentName
149
146
},
150
-
'docs-url': docUrl,
151
-
description: `'${componentName}' - BootstrapVue component '${tagName}'`,
147
+
'doc-url': docUrl,
148
+
description: groupDescription,
152
149
attributes: []
153
150
}
154
151
@@ -170,14 +167,15 @@ const processComponentMeta = (meta, groupRef, docUrl) => {
170
167
const prop = {
171
168
name: propName,
172
169
value: {
173
-
type: type,
174
-
default: computePropDefault($prop)
170
+
kind: 'expression',
171
+
type: type
175
172
},
173
+
default: computePropDefault($prop),
176
174
'doc-url': docUrl
177
175
}
178
176
// Add required prop is required
179
177
if ($prop.required) {
180
-
prop.value.required = true
178
+
prop.required = true
181
179
}
182
180
if (type === 'boolean') {
183
181
// Deprecated. Use 'value' property instead. Specify only if type is
@@ -215,10 +213,11 @@ const processComponentMeta = (meta, groupRef, docUrl) => {
215
213
event.description = eventObj.description
216
214
}
217
215
if (Array.isArray(eventObj.args)) {
218
-
event.arguments = eventObj.args.map(arg => {
216
+
event.arguments = eventObj.args.map((arg, index) => {
219
217
arg = typeof arg === 'object' ? arg : { arg: arg }
218
+
const name = arg.arg || (arg.type ? computePropType(arg) : undefined) || 'arg' + index
220
219
const argument = {
221
-
name: arg.arg,
220
+
name: name.charAt(0).toLowerCase() + name.slice(1),
222
221
'doc-url': docUrl
223
222
}
224
223
if (arg.description) {
@@ -278,14 +277,14 @@ const processComponentMeta = (meta, groupRef, docUrl) => {
278
277
// Add the aliases
279
278
$aliases.forEach(alias => {
280
279
const aliasTag = { ...tag, name: alias, source: { ...tag.source, symbol: alias } }
281
-
aliasTag.description = `'${alias}' '${kebabCase(alias)}' (Alias for ${tag.description})`
280
+
aliasTag.description = `${tag.description}\n\n*Alias for ${tag.name}*`
282
281
webTypes.contributions.html.tags.push(aliasTag)
283
282
})
284
283
}
285
284
}
286
285
287
286
// Process a single directive meta object
288
-
const processDirectiveMeta = (directiveMeta, docUrl) => {
287
+
const processDirectiveMeta = (directiveMeta, directiveDescription, docUrl) => {
289
288
// Process the directive meta
290
289
// String (PascalCase)
291
290
const name = directiveMeta.directive
@@ -304,18 +303,17 @@ const processDirectiveMeta = (directiveMeta, docUrl) => {
304
303
symbol: name
305
304
},
306
305
required: false,
307
-
description: `${name} - BootstrapVue directive '${kebabCase(name)}'`,
306
+
description: directiveDescription,
308
307
'doc-url': docUrl
309
308
}
310
309
311
310
// Add in argument details
312
311
if (arg) {
313
-
// TODO as this is missing from the schema def
314
-
// https://github.com/JetBrains/web-types/issues/7
315
312
attribute['vue-argument'] = {
316
313
// RegExpr string pattern for argument
317
314
pattern: arg.pattern,
318
-
description: arg.description
315
+
description: arg.description,
316
+
required: arg.required
319
317
}
320
318
}
321
319
@@ -363,13 +361,13 @@ const processComponentGroup = groupSlug => {
363
361
364
362
// Process each component
365
363
componentsMeta.forEach(meta => {
366
-
processComponentMeta(meta, groupRef, docUrl)
364
+
processComponentMeta(meta, groupRef, groupMeta.description, docUrl)
367
365
})
368
366
369
367
// Process any directives provided in the meta
370
368
// These directives do not have their own package.json files
371
369
directivesMeta.forEach(directiveMeta => {
372
-
processDirectiveMeta(directiveMeta, docUrl)
370
+
processDirectiveMeta(directiveMeta, groupMeta.description, docUrl)
373
371
})
374
372
}
375
373
@@ -380,7 +378,7 @@ const processDirectiveGroup = groupSlug => {
380
378
const docUrl = `${baseDocs}/docs/directives/${groupSlug}/`
381
379
382
380
// Process the directive meta
383
-
processDirectiveMeta(directiveMeta, docUrl)
381
+
processDirectiveMeta(directiveMeta, directiveMeta.description, docUrl)
384
382
}
385
383
386
384
// Wrapped in a try/catch to handle any errors
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4