npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

components-helper

v2.2.0

Published

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

Downloads

1,319

Readme

: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

entry

  • Required: true
  • Type: string | string[]

Specify the entry directory. refer: fast-glob

for example:

  • docs/*.md -- matches all files in the docs
  • docs/(a|b).md -- matches files a.md and b.md
  • docs/!(a|b).md -- matches files except for a.md and b.md

fastGlobConfig

  • Type: object

The config of fast-glob

outDir

  • Required: true
  • Type: string

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

name

  • Required: true
  • Type: string

name of the component library.

version

  • Required: true
  • Type: string

the version of the component library.

space

  • Type: number | string

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

separator

  • Type: string
  • Default: /

the separator for propsOptions, slotsSubtags, type ...

reComponentName

  • 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()

reDocUrl

  • Type: (fileName: string, header?: string, path: string) => string | undefind

rewriting the doc url of the component

reAttribute

  • Type: (value: string, key: string, row: string[], title: string) => string | undefined
arg
  • 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

reVeturDescription

  • Type: (description?: string, defaultValue?: string, docUrl?: string) => string
  • Default: same like ${description}, default: ${defaultValue}.\n\n[Docs](${docUrl})

rewriting the description of vetur

reWebTypesSource

  • Type: (title: string, fileName: string, path: string) => Source

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

reWebTypesType

  • Type: (type: string) => undefined | string | BaseContribution

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

  • Type: string
  • Default: tags.json

name for tags of the vetur

attributes

  • Type: string
  • Default: attributes.json

name for attributes of the Vetur

webTypes

  • Type: string
  • Default: web-types.json

name for web-types of the WebStorm

props

  • Type: string (This is a regular string and ignores case.)
  • Default: props

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

propsName

  • Type: string
  • Default: Name

The header name of the Name in the props table

propsDescription

  • Type: string
  • Default: Description

The header name of the Description in the props table

propsType

  • Type: string
  • Default: Type

The header name of the Type in the props table

propsOptions

  • Type: string
  • Default: Options

The header name of the Options in the props table

propsDefault

  • Type: string
  • Default: Default

The header name of the Default in the props table

events

  • Type: string (This is a regular string and ignores case.)
  • Default: events

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

eventsName

  • Type: string
  • Default: Name

The header name of the Name in the events table

eventsDescription

  • Type: string
  • Default: Description

The header name of the Description in the events table

slots

  • Type: string (This is a regular string and ignores case.)
  • Default: slots

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

slotsName

  • Type: string
  • Default: Name

The header name of the Name in the slots table

slotsDescription

  • Type: string
  • Default: 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

The header name of the Subtags in the slots table

directives

  • Type: string (This is a regular string and ignores case.)
  • Default: directives

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

directivesName

  • Type: string
  • Default: Name

The header name of the Name in the directives table

directivesDescription

  • Type: string
  • Default: Description

The header name of the Description in the directives table

directivesType

  • Type: string
  • Default: Type

The header name of the Type in the directives table

titleRegExp

  • Type: RegExp | string (This is a regular string.)
  • Default: /#+\s+(.*)\n+([^(#|\n)]*)/g

matches the title and description information from docs

tableRegExp

  • Type: RegExp | string (This is a regular string.)
  • Default: /#+\s+(.*)\n+(\|?.+\|.+)\n\|?\s*:?-+:?\s*\|.+((\n\|?.+\|.+)+)/g

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

fileNameRegExp

  • Type: RegExp | string (This is a regular string.)
  • Default: /\/((\w|-)+)\.\w+$/

matches the file name from the path

Advancement

about titleRegExp

matches the first format information in the docs

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

and

matches other formats, For example:

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

about tableRegExp

matches the format information in the docs

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

and

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

and

other

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

License

MIT