mirror of
https://github.com/youzan/vant.git
synced 2025-10-22 11:54:02 +00:00
chore: prettier packages codes
This commit is contained in:
@@ -65,7 +65,7 @@ export function codegen(artical: Artical) {
|
||||
const key = camelCaseToKebabCase(match[1] || 'default');
|
||||
const tag: Tag = tags[key] || {
|
||||
description: tagDescription,
|
||||
attributes: {}
|
||||
attributes: {},
|
||||
};
|
||||
|
||||
tags[key] = tag;
|
||||
@@ -77,7 +77,7 @@ export function codegen(artical: Artical) {
|
||||
|
||||
const attr: Attribute = {
|
||||
description: getDescription(td, isProp),
|
||||
type: isProp ? td[2].replace(/`/g, '').toLowerCase() : 'event'
|
||||
type: isProp ? td[2].replace(/`/g, '').toLowerCase() : 'event',
|
||||
};
|
||||
|
||||
tag.attributes[name] = attr;
|
||||
|
@@ -8,7 +8,7 @@ import {
|
||||
existsSync,
|
||||
readdirSync,
|
||||
readFileSync,
|
||||
writeFileSync
|
||||
writeFileSync,
|
||||
} from 'fs';
|
||||
|
||||
export function parseText(input: string) {
|
||||
@@ -43,18 +43,18 @@ export type ParseResult = {
|
||||
|
||||
const defaultOptions = {
|
||||
maxDeep: Infinity,
|
||||
tagPrefix: ''
|
||||
tagPrefix: '',
|
||||
};
|
||||
|
||||
export function parse(options: Options) {
|
||||
options = {
|
||||
...defaultOptions,
|
||||
...options
|
||||
...options,
|
||||
};
|
||||
|
||||
const result: ParseResult = {
|
||||
tags: {},
|
||||
attributes: {}
|
||||
attributes: {},
|
||||
};
|
||||
|
||||
function putResult(componentName: string, component: Tag) {
|
||||
@@ -62,7 +62,7 @@ export function parse(options: Options) {
|
||||
const attributes = Object.keys(component.attributes);
|
||||
const tag = {
|
||||
description: component.description,
|
||||
attributes
|
||||
attributes,
|
||||
};
|
||||
|
||||
result.tags[componentName] = tag;
|
||||
@@ -85,7 +85,7 @@ export function parse(options: Options) {
|
||||
recursiveParse(
|
||||
{
|
||||
...options,
|
||||
path: currentPath
|
||||
path: currentPath,
|
||||
},
|
||||
deep
|
||||
);
|
||||
@@ -123,7 +123,10 @@ export function parseAndWrite(options: Options) {
|
||||
mkdirSync(options.outputDir);
|
||||
}
|
||||
|
||||
writeFileSync(join(options.outputDir, 'tags.json'), JSON.stringify(tags, null, 2));
|
||||
writeFileSync(
|
||||
join(options.outputDir, 'tags.json'),
|
||||
JSON.stringify(tags, null, 2)
|
||||
);
|
||||
writeFileSync(
|
||||
join(options.outputDir, 'attributes.json'),
|
||||
JSON.stringify(attributes, null, 2)
|
||||
@@ -133,5 +136,5 @@ export function parseAndWrite(options: Options) {
|
||||
export default {
|
||||
parse,
|
||||
parseText,
|
||||
parseAndWrite
|
||||
parseAndWrite,
|
||||
};
|
||||
|
@@ -43,7 +43,7 @@ function tableParse(input: string) {
|
||||
const end = input.length;
|
||||
const table: TableContent = {
|
||||
head: [],
|
||||
body: []
|
||||
body: [],
|
||||
};
|
||||
|
||||
while (start < end) {
|
||||
@@ -69,7 +69,7 @@ function tableParse(input: string) {
|
||||
|
||||
return {
|
||||
table,
|
||||
usedLength: start
|
||||
usedLength: start,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ export function mdParser(input: string): Array<SimpleMdAst> {
|
||||
artical.push({
|
||||
type: 'title',
|
||||
content: match[2],
|
||||
level: match[1].length
|
||||
level: match[1].length,
|
||||
});
|
||||
|
||||
start += match.index + match[0].length;
|
||||
@@ -94,7 +94,7 @@ export function mdParser(input: string): Array<SimpleMdAst> {
|
||||
const { table, usedLength } = tableParse(target.substr(match.index));
|
||||
artical.push({
|
||||
type: 'table',
|
||||
table
|
||||
table,
|
||||
});
|
||||
|
||||
start += match.index + usedLength;
|
||||
|
Reference in New Issue
Block a user