feat(markdown-vetur): 支持生成 attributes.json 的 options 属性 (#8545)
* feat(markdown-vetur): 支持生成 attributes.json 的 options 属性 * fix(markdown-vetur): 没有可选值不添加 options 属性
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { VueTag, VeturTags, VeturAttributes } from './type';
|
||||
import { VueTag, VeturTags, VeturAttributes, VeturAttribute } from './type';
|
||||
|
||||
export function genVeturTags(tags: VueTag[]) {
|
||||
const veturTags: VeturTags = {};
|
||||
@@ -18,10 +18,16 @@ export function genVeturAttributes(tags: VueTag[]) {
|
||||
tags.forEach(tag => {
|
||||
if (tag.attributes) {
|
||||
tag.attributes.forEach(attr => {
|
||||
veturAttributes[`${tag.name}/${attr.name}`] = {
|
||||
let attribute: VeturAttribute = {
|
||||
type: attr.value.type,
|
||||
description: `${attr.description}, 默认值: ${attr.default}`,
|
||||
};
|
||||
description: `${attr.description}, 默认值: ${attr.default}`
|
||||
}
|
||||
|
||||
if (attr.options.length > 0) {
|
||||
attribute.options = attr.options
|
||||
}
|
||||
|
||||
veturAttributes[`${tag.name}/${attr.name}`] = attribute;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user