Home

Awesome

:warning: This library is no longer maintained.

With the WebStorm support of Volar, you may no longer need this library.

It is more recommended that you use Volar's code prompt by improving the type declaration.

If you still need this library, you can continue to use it, but this library will no longer have new feature updates.


components-helper

Based on the documents to provide code prompt files for vue component library

Reference documents format reference test files

Changelog

Installation

yarn add components-helper -D
# or
npm i components-helper --save-dev

Usage

const { main } = require('components-helper')

main({
  // Options
})

example

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"
}

Options

<details> <summary>TOC</summary> </details>

entry

Specify the entry directory. refer: fast-glob

for example:

fastGlobConfig

The config of fast-glob

outDir

Specify the output directory. For example, `lib``

name

name of the component library.

version

the version of the component library.

space

Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read

separator

the separator for propsOptions, slotsSubtags, type ...

reComponentName

rewriting the name of the component

for example (title) => 'prefix-' + title.replace(/\B([A-Z])/g, '-$1').toLowerCase()

reDocUrl

rewriting the doc url of the component

reAttribute

arg

rewriting the attribute of the component

reVeturDescription

rewriting the description of vetur

reWebTypesSource

rewriting the source of web-types. (the name of export from the component library)

reWebTypesType

Only some common types are processed internally, and the rest are exported from the component library by default. If your document also references types in third-party libraries, you can choose to override the relevant behavior through this function

tags

name for tags of the vetur

attributes

name for attributes of the Vetur

webTypes

name for web-types of the WebStorm

props

The title of the props table. other string in the header will be identified as sub-component

propsName

The header name of the Name in the props table

propsDescription

The header name of the Description in the props table

propsType

The header name of the Type in the props table

propsOptions

The header name of the Options in the props table

propsDefault

The header name of the Default in the props table

events

The title of the events table. other string in the header will be identified as sub-component

eventsName

The header name of the Name in the events table

eventsDescription

The header name of the Description in the events table

slots

The title of the slots table. other string in the header will be identified as sub-component

slotsName

The header name of the Name in the slots table

slotsDescription

The header name of the Description in the slots table

slotsType

The header name of the Type in the slots table

slotsSubtags

The header name of the Subtags in the slots table

directives

The title of the directives table. other string in the header will be identified as sub-component

directivesName

The header name of the Name in the directives table

directivesDescription

The header name of the Description in the directives table

directivesType

The header name of the Type in the directives table

titleRegExp

matches the title and description information from docs

tableRegExp

matches the title and table header and the table contains information from docs

fileNameRegExp

matches the file name from the path

Advancement

about titleRegExp

matches the first format information in the docs

/#+\s+(.*)\n+([^(#|\n)]*)/

<div> # <code>title</code> <div><code>description</code></div> </div>

and

<div> ## <code>title</code> </div>

matches other formats, For example:

/#+\s+(.*)\n+>\s*([^(#|\n)]*)/g

<div> # <code>title</code> <div>> <code>description</code></div> </div>

about tableRegExp

matches the format information in the docs

/#+\s+(.*)\n+(\|?.+\|.+)\n|?\s*:?-+:?\s*|.+((\n\|?.+\|.+)+)/g

<div> ### <code>title</code> <div><code>| header |</code></div> <div>| ------ |</div> <div><code>| column |</code></div> <div><code>| column |</code></div> </div>

and

<div> ### <code>sub-component title</code> <div><code>| header |</code></div> <div>| :----- |</div> <div><code>| column |</code></div> <div><code>| column |</code></div> </div>

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

<div> ### <code>Props / Events / Slots / Directives</code> <div><code>| header |</code></div> <div>| ------ |</div> <div><code>| column |</code></div> <div><code>| column |</code></div> </div>

and

<div> ### <code>sub-component Props</code> <div><code>| header |</code></div> <div>| ------ |</div> <div><code>| column |</code></div> <div><code>| column |</code></div> </div>

other

When this document does not include the primary title or Props Events Slots and Directives, this component is not created.

License

MIT