Skip to content

Commit 6335f4e

Browse files
committed
feat(api): fill "meta" > docsUrl prop; build improvements
1 parent 9555037 commit 6335f4e

File tree

125 files changed

+390
-138
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+390
-138
lines changed

app/bin/quasar-describe

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ function describe (api) {
483483
apiParts.methods === true && printMethods(api)
484484
break
485485
}
486+
486487
if (apiParts.docs && api.meta && api.meta.docsUrl) {
487488
openBrowser(api.meta.docsUrl)
488489
}

ui/build/build.api.js

Lines changed: 9 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ const
22
glob = require('glob'),
33
path = require('path'),
44
merge = require('webpack-merge'),
5-
fs = require('fs'),
6-
request = require('request')
5+
fs = require('fs')
76

87
const
98
root = path.resolve(__dirname, '..'),
@@ -38,8 +37,8 @@ function getMixedInAPI (api, mainFile) {
3837

3938
const topSections = {
4039
plugin: [ 'meta', 'injection', 'quasarConfOptions', 'props', 'methods' ],
41-
component: ['meta', 'behavior', 'props', 'slots', 'scopedSlots', 'events', 'methods'],
42-
directive: ['meta', 'value', 'arg', 'modifiers']
40+
component: [ 'meta', 'behavior', 'props', 'slots', 'scopedSlots', 'events', 'methods' ],
41+
directive: [ 'meta', 'value', 'arg', 'modifiers' ]
4342
}
4443

4544
const objectTypes = {
@@ -119,7 +118,7 @@ const objectTypes = {
119118
},
120119

121120
meta: {
122-
props: [ 'docsRoute', 'docsPage', 'docsApiAnchor' ],
121+
props: [ 'docsUrl' ],
123122
required: []
124123
},
125124

@@ -220,7 +219,6 @@ function parseObject ({ banner, api, itemName, masterType, verifyCategory }) {
220219
}
221220

222221
if (!def.props.includes(prop)) {
223-
console.log(def)
224222
logError(`${banner} object has unrecognized API prop "${prop}" for its type (${type})`)
225223
console.error(obj)
226224
console.log()
@@ -350,28 +348,18 @@ function parseAPI (file, apiType) {
350348
continue
351349
}
352350

353-
if (['value', 'arg', 'quasarConfOptions'].includes(type)) {
351+
if (['value', 'arg', 'quasarConfOptions', 'meta'].includes(type)) {
354352
if (Object(api[type]) !== api[type]) {
355353
logError(`${banner} "${type}"/"${type}" is not an object`)
356354
process.exit(1)
357355
}
358356
}
359357

360-
if (type === 'quasarConfOptions') {
358+
if (['meta', 'quasarConfOptions'].includes(type)) {
361359
parseObject({
362360
banner: `${banner} "${type}"`,
363361
api,
364-
itemName: 'quasarConfOptions',
365-
masterType: type
366-
})
367-
continue
368-
}
369-
370-
if (type === 'meta') {
371-
parseObject({
372-
banner: `${banner} "${type}"`,
373-
api,
374-
itemName: 'meta',
362+
itemName: type,
375363
masterType: type
376364
})
377365
continue
@@ -403,33 +391,7 @@ function parseAPI (file, apiType) {
403391
return api
404392
}
405393

406-
const routes = {
407-
component: 'vue-components',
408-
directive: 'vue-directives',
409-
plugin: 'quasar-plugins'
410-
}
411-
412-
function getPage (fileName) {
413-
let page
414-
if (fileName.startsWith('Q')) {
415-
page = fileName.slice(1)
416-
}
417-
else {
418-
page = fileName
419-
}
420-
// kebab-case
421-
return page.replace(/([a-z])([A-Z])/g, '$1-$2').replace(/[\s_]+/g, '-').toLowerCase()
422-
}
423-
424-
function orderAPI (api, apiType, fileName) {
425-
const metaDef = api.meta || {},
426-
meta = {},
427-
docsApiAnchor = metaDef.docsApiAnchor === void 0
428-
? (apiType === 'directive' ? 'API' : fileName + '-API')
429-
: metaDef.docsApiAnchor
430-
// TODO change URL to v1.quasar.dev
431-
meta.docsUrl = `https://quasar.dev/${metaDef.docsRoute || routes[apiType]}/${metaDef.docsPage || getPage(fileName)}#${docsApiAnchor}`
432-
394+
function orderAPI (api, apiType) {
433395
const ordered = {
434396
type: apiType
435397
}
@@ -440,8 +402,6 @@ function orderAPI (api, apiType, fileName) {
440402
}
441403
})
442404

443-
ordered.meta = meta
444-
445405
return ordered
446406
}
447407

@@ -489,7 +449,7 @@ function fillAPI (apiType) {
489449
name = path.basename(file),
490450
filePath = path.join(dest, name)
491451

492-
const api = orderAPI(parseAPI(file, apiType), apiType, name.replace('.json', ''))
452+
const api = orderAPI(parseAPI(file, apiType), apiType)
493453

494454
if (apiType === 'component') {
495455
const definition = fs.readFileSync(file.replace('.json', '.js'), {

ui/src/components/ajax-bar/QAjaxBar.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{
2+
"meta": {
3+
"docsUrl": "https://v1.quasar.dev/vue-components/ajax-bar"
4+
},
5+
26
"props": {
37
"position": {
48
"type": "String",

ui/src/components/avatar/QAvatar.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"mixins": [ "mixins/size" ],
33

4+
"meta": {
5+
"docsUrl": "https://v1.quasar.dev/vue-components/avatar"
6+
},
7+
48
"behavior": {
59
"$listeners": true
610
},

ui/src/components/badge/QBadge.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{
2+
"meta": {
3+
"docsUrl": "https://v1.quasar.dev/vue-components/badge"
4+
},
5+
26
"behavior": {
37
"$listeners": true
48
},

ui/src/components/banner/QBanner.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{
2+
"meta": {
3+
"docsUrl": "https://v1.quasar.dev/vue-components/banner"
4+
},
5+
26
"behavior": {
37
"$listeners": true
48
},

ui/src/components/bar/QBar.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{
2+
"meta": {
3+
"docsUrl": "https://v1.quasar.dev/vue-components/bar"
4+
},
5+
26
"behavior": {
37
"$listeners": true
48
},

ui/src/components/breadcrumbs/QBreadcrumbs.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{
2+
"meta": {
3+
"docsUrl": "https://v1.quasar.dev/vue-components/breadcrumbs"
4+
},
5+
26
"behavior": {
37
"$listeners": true
48
},

ui/src/components/breadcrumbs/QBreadcrumbsEl.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"meta": {
3-
"docsPage": "breadcrumbs"
3+
"docsUrl": "https://v1.quasar.dev/vue-components/breadcrumbs"
44
},
55

66
"mixins": [ "mixins/router-link" ],

ui/src/components/btn-dropdown/QBtnDropdown.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"mixins": [ "mixins/btn", "mixins/model-toggle" ],
33

44
"meta": {
5-
"docsPage": "button-dropdown"
5+
"docsUrl": "https://v1.quasar.dev/vue-components/button-dropdown"
66
},
77

88
"props": {

0 commit comments

Comments
 (0)