From 1cc90565ff4596f105fc0e7b3eb0f68c0ff23410 Mon Sep 17 00:00:00 2001 From: tolking Date: Wed, 28 Sep 2022 23:22:18 +0800 Subject: [PATCH] feat: add config slotsType --- README.md | 48 ++++++++++++++++++++++++++++-------------------- src/config.ts | 1 + src/type.ts | 3 ++- src/webTypes.ts | 2 ++ test/demo.md | 8 ++++---- 5 files changed, 37 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 7f226f5..af9b25d 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,7 @@ then in package.json - [slots](#slots) - [slotsName](#slotsname) - [slotsDescription](#slotsdescription) +- [slotsType](#slotsType) - [slotsSubtags](#slotssubtags) - [directives](#directives) - [directivesName](#directivesname) @@ -89,7 +90,7 @@ then in package.json - Required: `true` - Type: `string` -entry path, refer: [fast-glob](https://github.com/mrmlnc/fast-glob#pattern-syntax) +Specify the entry directory. refer: [fast-glob](https://github.com/mrmlnc/fast-glob#pattern-syntax) for example: - `docs/*.md` -- matches all files in the docs @@ -101,7 +102,7 @@ for example: - Required: `true` - Type: `string` -outDir path, For example `lib` +Specify the output directory. For example, `lib`` ### name @@ -203,119 +204,126 @@ name for web-types of the WebStorm - Type: `string` (**This is a regular string and ignores case.**) - Default: `props` -name of props table. **other string in the header will be identified as sub-component** +The title of the props table. **other string in the header will be identified as sub-component** ### propsName - Type: `string` - Default: `Name` -name for the props header name +The header name of the `Name` in the props table ### propsDescription - Type: `string` - Default: `Description` -name for props header description +The header name of the `Description` in the props table ### propsType - Type: `string` - Default: `Type` -name for props header type +The header name of the `Type` in the props table ### propsOptions - Type: `string` - Default: `Options` -name for props header options +The header name of the `Options` in the props table ### propsDefault - Type: `string` - Default: `Default` -name for props header default +The header name of the `Default` in the props table ### events - Type: `string` (**This is a regular string and ignores case.**) - Default: `events` -name of events table. **other string in the header will be identified as sub-component** +The title of the events table. **other string in the header will be identified as sub-component** ### eventsName - Type: `string` - Default: `Name` -name for the events header name +The header name of the `Name` in the events table ### eventsDescription - Type: `string` - Default: `Description` -name for events header description +The header name of the `Description` in the events table ### slots - Type: `string` (**This is a regular string and ignores case.**) - Default: `slots` -name of slots table. **other string in the header will be identified as sub-component** +The title of the slots table. **other string in the header will be identified as sub-component** ### slotsName - Type: `string` - Default: `Name` -name for the slots header name +The header name of the `Name` in the slots table ### slotsDescription - Type: `string` - Default: `Description` -name for slots header description +The header name of the `Description` in the slots table + +### slotsType + +- Type: `string` +- Default: `Type` + +The header name of the `Type` in the slots table ### slotsSubtags - Type: `string` - Default: `Subtags` -name for slots header subtags +The header name of the `Subtags` in the slots table ### directives - Type: `string` (**This is a regular string and ignores case.**) - Default: `directives` -name of directives table. **other string in the header will be identified as sub-component** +The title of the directives table. **other string in the header will be identified as sub-component** ### directivesName - Type: `string` - Default: `Name` -name for the directives header name +The header name of the `Name` in the directives table ### directivesDescription - Type: `string` - Default: `Description` -name for directives header description +The header name of the `Description` in the directives table ### directivesType - Type: `string` - Default: `Type` -name for directives header type +The header name of the `Type` in the directives table ### titleRegExp @@ -395,7 +403,7 @@ by default matches all tables, Optimize it through tableRegExp, For example: /#+\s+(`.*\s*Props|.*\s*Events|.*\s*Slots|.*\s*Directives`)\n+(`\|?.+\|.+`)\n\|?\s*:?-+:?\s*\|.+(`(\n\|?.+\|.+)+`)/g
-### Props | Events | Slots | Directives +### Props / Events / Slots / Directives
| header |
| ------ |
| column |
diff --git a/src/config.ts b/src/config.ts index 674cf8b..414b7c0 100644 --- a/src/config.ts +++ b/src/config.ts @@ -20,6 +20,7 @@ export const config: Config = { slots: 'slots', slotsName: 'Name', slotsDescription: 'Description', + slotsType: 'Type', slotsSubtags: 'Subtags', directives: 'directives', directivesName: 'Name', diff --git a/src/type.ts b/src/type.ts index 25c1d87..3c92c66 100644 --- a/src/type.ts +++ b/src/type.ts @@ -67,6 +67,7 @@ export interface Config { slots: string slotsName: string slotsDescription: string + slotsType: string slotsSubtags: string directives: string directivesName: string @@ -244,7 +245,7 @@ export type NamePattern = export type Required = boolean export type NamePatternTemplate = [ string | NamePatternTemplate | NamePattern, - ...(string | NamePatternTemplate | NamePattern)[] + ...(string | NamePatternTemplate | NamePattern)[], ] /** * A reference to an element in Web-Types model. diff --git a/src/webTypes.ts b/src/webTypes.ts index 6bbc4f6..32bc8b3 100644 --- a/src/webTypes.ts +++ b/src/webTypes.ts @@ -47,6 +47,7 @@ export function getWebTypes(options: Options, list: NormalizeData[]) { eventsDescription, slotsName, slotsDescription, + slotsType, directivesName, directivesType, directivesDescription, @@ -142,6 +143,7 @@ export function getWebTypes(options: Options, list: NormalizeData[]) { name: _item, description: item[slotsDescription], 'doc-url': getDocUrl(options, fileName, slots?.title, path), + type: item[slotsType], }) } }) diff --git a/test/demo.md b/test/demo.md index 5fafb4b..7b930da 100644 --- a/test/demo.md +++ b/test/demo.md @@ -28,10 +28,10 @@ This is a description of the Demo component ## Slots -| Name | Description | Subtags | -| ---- | ----------- | ------- | -| default | customize button group content | DemoItem / DemoGroup | -| other | some other slots || +| Name | Description | Type | Subtags | +| ---- | ----------- | ---- | ------- | +| default | customize button group content || DemoItem / DemoGroup | +| other | some other slots | { data: any } || ## Directives