🌐 AI搜索 & 代理 主页
Skip to content

Commit 0ddb2e0

Browse files
authored
feat(docs): auto-detect settings props in component reference (#5761)
1 parent 38eea23 commit 0ddb2e0

File tree

37 files changed

+11
-172
lines changed

37 files changed

+11
-172
lines changed

docs/common-props.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@
239239
},
240240
"routerComponentName": {
241241
"description": "<b-link> prop: BootstrapVue auto detects between `<router-link>` and `<nuxt-link>`. In cases where you want to use a 3rd party link component based on `<router-link>`, set this prop to the component name. e.g. set it to 'g-link' if you are using Gridsome (note only `<router-link>` specific props are passed to the component)",
242-
"version": "2.15.0",
243-
"settings": true
242+
"version": "2.15.0"
244243
}
245244
}

docs/components/componentdoc.vue

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,8 @@ ul.component-ref-mini-toc:empty {
320320

321321
<script>
322322
import Vue from 'vue'
323-
// Fallback descriptions for common props (mainly router-link props)
324323
import commonProps from '../common-props.json'
324+
import { defaultConfig } from '../content'
325325
import { kebabCase } from '../utils'
326326
import AnchoredHeading from './anchored-heading'
327327
@@ -448,10 +448,15 @@ export default {
448448
propsItems() {
449449
const props = this.componentProps
450450
const propsMetaObj = this.componentPropsMetaObj
451+
const componentSettings = defaultConfig[this.componentOptions.name] || {}
451452
452453
return Object.keys(props).map(prop => {
453454
const p = props[prop]
454-
const meta = propsMetaObj[prop] || {}
455+
const meta = {
456+
// Fallback descriptions for common props
457+
...(commonProps[prop] || {}),
458+
...(propsMetaObj[prop] || {})
459+
}
455460
456461
// Describe type
457462
let type = p.type
@@ -475,24 +480,16 @@ export default {
475480
? ''
476481
: String(JSON.stringify(defaultValue, undefined, 1)).replace(/"/g, "'")
477482
478-
const fallbackMeta = commonProps[prop] || {}
479-
const description =
480-
typeof meta.description === 'undefined' ? fallbackMeta.description : meta.description
481-
// TODO:
482-
// Can we auto-detect this by doing a lookup in the
483-
// default settings or determine if the prop default
484-
// value came from the settings?
485-
const settings = meta.settings || false
486-
const version = typeof meta.version === 'undefined' ? fallbackMeta.version : meta.version
483+
const settings = Object.prototype.hasOwnProperty.call(componentSettings, prop)
487484
488485
return {
489486
prop: kebabCase(prop),
490487
type,
491488
defaultValue,
492489
required: p.required || false,
493-
description: description || '',
490+
description: meta.description || '',
491+
version: meta.version || '',
494492
settings,
495-
version,
496493
xss: /[a-z]Html$/.test(prop),
497494
isVModel: this.componentVModel && this.componentVModel.prop === prop,
498495
deprecated: p.deprecated || false,

src/components/alert/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"props": [
1111
{
1212
"prop": "variant",
13-
"settings": true,
1413
"description": "Applies one of the Bootstrap theme color variants to the component"
1514
},
1615
{
@@ -19,7 +18,6 @@
1918
},
2019
{
2120
"prop": "dismissLabel",
22-
"settings": true,
2321
"description": "Value for the 'aria-label' attribute on the dismiss button"
2422
},
2523
{

src/components/avatar/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"props": [
1313
{
1414
"prop": "variant",
15-
"settings": true,
1615
"description": "Applies one of the Bootstrap theme color variants to the component"
1716
},
1817
{
@@ -60,7 +59,6 @@
6059
{
6160
"prop": "badgeVariant",
6261
"version": "2.12.0",
63-
"settings": true,
6462
"description": "Applies one of the Bootstrap theme color variants to the badge"
6563
},
6664
{

src/components/badge/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"props": [
1111
{
1212
"prop": "variant",
13-
"settings": true,
1413
"description": "Applies one of the Bootstrap theme color variants to the component"
1514
},
1615
{

src/components/button/package.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@
1313
"props": [
1414
{
1515
"prop": "size",
16-
"settings": true,
1716
"description": "Set the size of the component's appearance. 'sm', 'md' (default), or 'lg'"
1817
},
1918
{
2019
"prop": "variant",
21-
"settings": true,
2220
"description": "Applies one of the Bootstrap theme color variants to the component"
2321
},
2422
{
@@ -64,18 +62,15 @@
6462
"props": [
6563
{
6664
"prop": "content",
67-
"settings": true,
6865
"version": "2.3.0",
6966
"description": "The content of the close button"
7067
},
7168
{
7269
"prop": "textVariant",
73-
"settings": true,
7470
"description": "Applies one of the Bootstrap theme color variants to the text"
7571
},
7672
{
7773
"prop": "ariaLabel",
78-
"settings": true,
7974
"description": "Sets the value of 'aria-label' attribute on the rendered element"
8075
}
8176
],

src/components/calendar/package.json

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,15 @@
3434
},
3535
{
3636
"prop": "selectedVariant",
37-
"settings": true,
3837
"description": "Theme color variant to use for the selected date button"
3938
},
4039
{
4140
"prop": "todayVariant",
42-
"settings": true,
4341
"description": "Theme color variant to use for highlighting todays date button. Defaults to the `selectedVariant` prop"
4442
},
4543
{
4644
"prop": "navButtonVariant",
4745
"version": "2.17.0",
48-
"settings": true,
4946
"description": "Theme color variant to use for the navigation buttons"
5047
},
5148
{
@@ -112,68 +109,55 @@
112109
{
113110
"prop": "labelPrevDecade",
114111
"version": "2.11.0",
115-
"settings": true,
116112
"description": "Value of the `aria-label` and `title` attributes on the optional `Previous Decade` navigation button"
117113
},
118114
{
119115
"prop": "labelPrevYear",
120-
"settings": true,
121116
"description": "Value of the `aria-label` and `title` attributes on the `Previous Year` navigation button"
122117
},
123118
{
124119
"prop": "labelPrevMonth",
125-
"settings": true,
126120
"description": "Value of the `aria-label` and `title` attributes on the `Previous Month` navigation button"
127121
},
128122
{
129123
"prop": "labelCurrentMonth",
130-
"settings": true,
131124
"description": "Value of the `aria-label` and `title` attributes on the `Current Month` navigation button"
132125
},
133126
{
134127
"prop": "labelNextMonth",
135-
"settings": true,
136128
"description": "Value of the `aria-label` and `title` attributes on the `Next Month` navigation button"
137129
},
138130
{
139131
"prop": "labelNextYear",
140-
"settings": true,
141132
"description": "Value of the `aria-label` and `title` attributes on the `Next Year` navigation button"
142133
},
143134
{
144135
"prop": "labelNextDecade",
145136
"version": "2.11.0",
146-
"settings": true,
147137
"description": "Value of the `aria-label` and `title` attributes on the optional `Next Decade` navigation button"
148138
},
149139
{
150140
"prop": "labelSelected",
151-
"settings": true,
152141
"description": "Value of the `aria-label` attribute set on the calendar grid date button that is selected"
153142
},
154143
{
155144
"prop": "labelToday",
156-
"settings": true,
157145
"description": "Value of the `aria-label` attribute for the calendar grid date button to signify that the date is today's date"
158146
},
159147
{
160148
"prop": "labelNoDateSelected",
161-
"settings": true,
162149
"description": "Label to use when no date is currently selected"
163150
},
164151
{
165152
"prop": "labelCalendar",
166-
"settings": true,
167153
"description": "Value of the `aria-label` and `role-description` attributes applied to the calendar grid"
168154
},
169155
{
170156
"prop": "labelNav",
171-
"settings": true,
172157
"description": "Value of the `aria-label` attribute on to the calendar navigation button wrapper"
173158
},
174159
{
175160
"prop": "labelHelp",
176-
"settings": true,
177161
"description": "Help text that appears at the bottom of the calendar grid"
178162
},
179163
{

src/components/card/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@
122122
},
123123
{
124124
"prop": "subTitleTextVariant",
125-
"settings": true,
126125
"description": "Applies one of the Bootstrap theme color variants to the sub title text"
127126
}
128127
]

src/components/carousel/package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,18 @@
5656
},
5757
{
5858
"prop": "labelPrev",
59-
"settings": true,
6059
"description": "Sets the 'aria-label' value for the previous slide control"
6160
},
6261
{
6362
"prop": "labelNext",
64-
"settings": true,
6563
"description": "Sets the 'aria-label' value for the next slide control"
6664
},
6765
{
6866
"prop": "labelGotoSlide",
69-
"settings": true,
7067
"description": "Sets the prefix for the 'aria-label' on the slide indicator controls. Will be suffixed with the slide number (1 indexed)"
7168
},
7269
{
7370
"prop": "labelIndicators",
74-
"settings": true,
7571
"description": "Sets the 'aria-label' on the indicator controls wrapper"
7672
},
7773
{

src/components/dropdown/package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@
1313
"props": [
1414
{
1515
"prop": "size",
16-
"settings": true,
1716
"description": "Set the size of the component's appearance. 'sm', 'md' (default), or 'lg'"
1817
},
1918
{
2019
"prop": "variant",
21-
"settings": true,
2220
"description": "Applies one of the Bootstrap theme color variants to the component"
2321
},
2422
{
@@ -63,7 +61,6 @@
6361
},
6462
{
6563
"prop": "toggleText",
66-
"settings": true,
6764
"description": "ARIA label (sr-only) to set on the toggle when in split mode"
6865
},
6966
{
@@ -101,7 +98,6 @@
10198
},
10299
{
103100
"prop": "splitVariant",
104-
"settings": true,
105101
"description": "Applies one of the Bootstrap theme color variants to the split button. Defaults to the 'variant' prop value"
106102
},
107103
{

0 commit comments

Comments
 (0)