mirror of
https://gitee.com/vant-contrib/vant.git
synced 2026-07-14 09:41:05 +08:00
Compare commits
2 Commits
7217004dd8
...
248fd7016f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
248fd7016f | ||
|
|
04814e2ead |
@ -1,7 +1,7 @@
|
||||
/* eslint-disable no-continue */
|
||||
import { Articles } from './parser.js';
|
||||
import { formatType, removeVersion, toKebabCase } from './utils.js';
|
||||
import { VueEventArgument, VueTag } from './type.js';
|
||||
import { VueAttribute, VueEvent, VueEventArgument, VueTag } from './type.js';
|
||||
|
||||
function formatComponentName(name: string, tagPrefix: string) {
|
||||
return tagPrefix + toKebabCase(name);
|
||||
@ -105,21 +105,52 @@ export function formatter(
|
||||
const tag = findTag(vueTags, name);
|
||||
|
||||
table.body.forEach((line) => {
|
||||
const [name, desc, type, defaultVal] = line;
|
||||
const [_name, desc, _type, defaultVal] = line;
|
||||
const name = removeVersion(_name);
|
||||
const type = formatType(_type);
|
||||
|
||||
if (!tag.attributes) {
|
||||
tag.attributes = [];
|
||||
}
|
||||
|
||||
tag.attributes.push({
|
||||
name: removeVersion(name),
|
||||
const attribute: VueAttribute = {
|
||||
name,
|
||||
default: defaultVal,
|
||||
description: desc,
|
||||
value: {
|
||||
type: formatType(type),
|
||||
type,
|
||||
kind: 'expression',
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
if (name === 'v-model') {
|
||||
const modelValue = 'modelValue';
|
||||
// add `modelValue`
|
||||
tag.attributes.push({ ...attribute, name: modelValue });
|
||||
|
||||
if (type === 'boolean') {
|
||||
// fix: warning `is not a valid value for v-model` in JetBrains IDE
|
||||
// ref: https://github.com/JetBrains/web-types/issues/79#issuecomment-2045153333
|
||||
attribute.value = { ...attribute.value, type: type + ' ' };
|
||||
}
|
||||
|
||||
if (!tag.events) {
|
||||
tag.events = [];
|
||||
}
|
||||
|
||||
tag.events.push({
|
||||
name: `update:${modelValue}`,
|
||||
description: `${desc}\n\nEmitted when the value of \`${modelValue}\` prop changes.`,
|
||||
arguments: [
|
||||
{
|
||||
name: modelValue,
|
||||
type,
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
tag.attributes.push(attribute);
|
||||
});
|
||||
return;
|
||||
}
|
||||
@ -127,20 +158,21 @@ export function formatter(
|
||||
if (tableTitle.includes('Events')) {
|
||||
const name = getNameFromTableTitle(tableTitle, tagPrefix) || defaultName;
|
||||
const tag = findTag(vueTags, name);
|
||||
const events: VueEvent[] = [];
|
||||
|
||||
table.body.forEach((line) => {
|
||||
const [name, desc, args] = line;
|
||||
|
||||
if (!tag.events) {
|
||||
tag.events = [];
|
||||
}
|
||||
|
||||
tag.events.push({
|
||||
events.push({
|
||||
name: removeVersion(name),
|
||||
description: desc,
|
||||
arguments: formatArguments(args),
|
||||
});
|
||||
});
|
||||
|
||||
// for higher priority
|
||||
tag.events = events.concat(tag.events || []);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -17,6 +17,7 @@ async function readMarkdown(options: Options) {
|
||||
const mds = await glob(normalizePath(`${options.path}/**/*.md`));
|
||||
return mds
|
||||
.filter((md) => options.test.test(md))
|
||||
.sort((a, b) => a.localeCompare(b)) // keep order
|
||||
.map((path) => fse.readFileSync(path, 'utf-8'));
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/* eslint-disable no-cond-assign */
|
||||
const TITLE_REG = /^(#+)\s+([^\n]*)/;
|
||||
const TITLE_REG = /^(#+)\s+([^\r\n]*)/;
|
||||
const TABLE_REG = /^\|.+\r?\n\|\s*-+/;
|
||||
const TD_REG = /\s*`[^`]+`\s*|([^|`]+)/g;
|
||||
const TABLE_SPLIT_LINE_REG = /^\|\s*-/;
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
"@typescript-eslint/eslint-plugin": "^6.2.1",
|
||||
"@typescript-eslint/parser": "^6.2.1",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-vue": "^9.16.1"
|
||||
"eslint-plugin-vue": "^9.24.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^8.57.0",
|
||||
|
||||
17
pnpm-lock.yaml
generated
17
pnpm-lock.yaml
generated
@ -312,8 +312,8 @@ importers:
|
||||
specifier: ^9.1.0
|
||||
version: 9.1.0(eslint@8.57.0)
|
||||
eslint-plugin-vue:
|
||||
specifier: ^9.16.1
|
||||
version: 9.20.1(eslint@8.57.0)
|
||||
specifier: ^9.24.1
|
||||
version: 9.24.1(eslint@8.57.0)
|
||||
devDependencies:
|
||||
eslint:
|
||||
specifier: ^8.57.0
|
||||
@ -2997,19 +2997,20 @@ packages:
|
||||
eslint: 8.57.0
|
||||
dev: false
|
||||
|
||||
/eslint-plugin-vue@9.20.1(eslint@8.57.0):
|
||||
resolution: {integrity: sha512-GyCs8K3lkEvoyC1VV97GJhP1SvqsKCiWGHnbn0gVUYiUhaH2+nB+Dv1uekv1THFMPbBfYxukrzQdltw950k+LQ==}
|
||||
/eslint-plugin-vue@9.24.1(eslint@8.57.0):
|
||||
resolution: {integrity: sha512-wk3SuwmS1pZdcuJlokGYEi/buDOwD6KltvhIZyOnpJ/378dcQ4zchu9PAMbbLAaydCz1iYc5AozszcOOgZIIOg==}
|
||||
engines: {node: ^14.17.0 || >=16.0.0}
|
||||
peerDependencies:
|
||||
eslint: ^6.2.0 || ^7.0.0 || ^8.0.0
|
||||
eslint: ^6.2.0 || ^7.0.0 || ^8.0.0 || ^9.0.0
|
||||
dependencies:
|
||||
'@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0)
|
||||
eslint: 8.57.0
|
||||
globals: 13.24.0
|
||||
natural-compare: 1.4.0
|
||||
nth-check: 2.1.1
|
||||
postcss-selector-parser: 6.0.15
|
||||
semver: 7.6.0
|
||||
vue-eslint-parser: 9.4.0(eslint@8.57.0)
|
||||
vue-eslint-parser: 9.4.2(eslint@8.57.0)
|
||||
xml-name-validator: 4.0.0
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@ -4788,8 +4789,8 @@ packages:
|
||||
resolution: {integrity: sha512-qdGXCtoBrwqk1BT6r2+1Wcvl583ZVkuSZ3or7Y1O2w5AvWtlvvxwjGhmz5DdPJS9xqRdDlgTJ/38ehWnEi0tFA==}
|
||||
dev: true
|
||||
|
||||
/vue-eslint-parser@9.4.0(eslint@8.57.0):
|
||||
resolution: {integrity: sha512-7KsNBb6gHFA75BtneJsoK/dbZ281whUIwFYdQxA68QrCrGMXYzUMbPDHGcOQ0OocIVKrWSKWXZ4mL7tonCXoUw==}
|
||||
/vue-eslint-parser@9.4.2(eslint@8.57.0):
|
||||
resolution: {integrity: sha512-Ry9oiGmCAK91HrKMtCrKFWmSFWvYkpGglCeFAIqDdr9zdXmMMpJOmUJS7WWsW7fX81h6mwHmUZCQQ1E0PkSwYQ==}
|
||||
engines: {node: ^14.17.0 || >=16.0.0}
|
||||
peerDependencies:
|
||||
eslint: '>=6.0.0'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user