Based on the documents to provide code prompt files for vue component library
Reference documents format reference test files
yarn add components-helper -D
# or
npm i components-helper --save-dev
const helper = require('components-helper')
helper({
// Options
})
then in package.json
{
"scripts": {
+ "build:helper": "node helper/file.js"
},
+ "vetur": {
+ "tags": "config outDir/tags.json",
+ "attributes": "config outDir/attributes.json"
+ },
+ "web-types": "config outDir/web-types.json"
}
- entry (required)
- outDir (required)
- name (required)
- version (required)
- space
- separator
- reComponentName
- reDocUrl
- reAttribute
- reVeturDescription
- reWebTypesSource
- tags
- attributes
- webTypes
- props
- propsName
- propsDescription
- propsType
- propsOptions
- propsDefault
- events
- eventsName
- eventsDescription
- slots
- slotsName
- slotsDescription
- slotsSubtags
- directives
- directivesName
- directivesDescription
- directivesType
- titleRegExp
- tableRegExp
- fileNameRegExp
- Required:
true
- Type:
string
entry path, refer: fast-glob
for example:
docs/*.md
-- matches all files in the docsdocs/(a|b).md
-- matches filesa.md
andb.md
docs/!(a|b).md
-- matches files excepta.md
andb.md
- Required:
true
- Type:
string
outDir path
For example: lib
- Required:
true
- Type:
string
name of the component library.
- Required:
true
- Type:
string
version of the component library.
- Type:
number
|string
Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read
- Type:
string
- Default:
/
the separator for propsOptions, slotsSubtags, type ...
- Type:
(title: string, fileName: string, path: string) => string
- Defult:
hyphenate(title || fileName)
rewriting the name of the component
for example: (title) => 'prefix-' + title.replace(/\B([A-Z])/g, '-$1').toLowerCase()
- Type:
(fileName: string, header?: string, path: string) => string | undefind
rewriting the doc url of the component
- Type:
(value: string, key: string, row: string[], title: string) => string | undefined
- value: current value
- key: the key value of the current column
- row: all values of the current row
- title: the title of current tabel
rewriting the attribute of the component
- Type:
(description?: string, defaultValue?: string, docUrl?: string) => string
- Default: same like
${description}, default: ${defaultValue}.\n\n[Docs](${docUrl})
rewriting the description of vetur
- Type:
(title: string, fileName: string, path: string) => { module?: string; symbol: string } | { file: string; offset: number }
- Default:
{ symbol: title }
rewriting the source of web-types. (the name of export from conmonents library)
- Type:
string
- Default:
tags.json
name for tags of the vetur
- Type:
string
- Default:
attributes.json
name for attributes of the vetur
- Type:
string
- Default:
web-types.json
name for web-types of the webstrom
- 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
- Type:
string
- Default:
Name
name for props header name
- Type:
string
- Default:
Description
name for props header description
- Type:
string
- Default:
Type
name for props header type
- Type:
string
- Default:
Options
name for props header options
- Type:
string
- Default:
Default
name for props header default
- 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
- Type:
string
- Default:
Name
name for events header name
- Type:
string
- Default:
Description
name for events header description
- 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
- Type:
string
- Default:
Name
name for slots header name
- Type:
string
- Default:
Description
name for slots header description
- Type:
string
- Default:
Subtags
name for slots header subtags
- 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
- Type:
string
- Default:
Name
name for directives header name
- Type:
string
- Default:
Description
name for directives header description
- Type:
string
- Default:
Type
name for directives header type
- Type:
string
(This is a regular string.) - Default:
#+\\s+(.*)\\n+([^(#|\\n)]*)
matches the title and description information from docs
- Type:
string
(This is a regular string.) - Default:
#+\\s+(.*)\\n+(\\|?.+\\|.+)\\n\\|?\\s*:?-+:?\\s*\\|.+((\\n\\|?.+\\|.+)+)
matches the title and table header and table content information from docs
- Type:
string
(This is a regular string.) - Default:
\\/((\\w|-)+)\\.\\w+$
matches the file name from path
matches the first format information in the docs
#+\\s+(.*
)\\n+([^(#|\\n)]*
)
title
description
and
title
matches other formats, For example:
#+\\s+(.*
)\n+>\\s*([^(#|\\n)]*
)
title
description
matches the format information in the docs
#+\\s+(.*
)\\n+(\\|?.+\\|.+
)\\n\\|?\\s*:?-+:?\\s*\\|.+((\\n\\|?.+\\|.+)+
)
title
| header |
| column |
| column |
and
sub-component title
| header |
| column |
| column |
by default matches all table, Optimize it through tableRegExp, For example:
#+\\s+(.*\\s*Props|.*\\s*Events|.*\\s*Slots|.*\\s*Directives
)\\s*\\n+(\\|?.+\\|.+
)\\n\\|?\\s*:?-+:?\\s*\\|.+((\\n\\|?.+\\|.+)+
)
Props | Events | Slots | Directives
| header |
| column |
| column |
and
sub-component Props
| header |
| column |
| column |
- When this docs not included the primary title or
Props
Events
Slots
andDirectives
, this component are not created.