vue中组件为json文件
Vuedoc分析器 (The Vuedoc Parser)
Generate a JSON documentation for a SFC Vue component.
为SFC Vue组件生成JSON文档。
安装 (Install)
npm install --save @vuedoc/parser
特征 (Features)
Extract the component name (from the name field or from the filename)
提取组件名称(从名称字段或文件名中提取)
Extract the component description
提取组件描述
Keywords Support: You can define your own keywords with the
@
symbol like关键字支持:您可以使用
@
符号定义自己的关键字,例如
@author Jon Snow
@author Jon Snow
Extract component model
提取组件模型
Extract component props
提取道具
Extract component data
提取组件数据
Extract computed properties with dependencies
提取具有依赖性的计算属性
Extract component events
提取组件事件
Extract component slots
提取组件插槽
Extract component methods
提取成分方法
Class Component Support
类组件支持
Vue Property Decorator Support
Vue属性装饰器支持
JSDoc Support (
@param
andJSDoc支持(
@param
和
@return
tags)@return
标签)
选件 (Options)
name | description |
---|---|
filename | The filename to parse. Required unless filecontent is passed |
filecontent | The file content to parse. Required unless filename is passed |
encoding | The file encoding. Default is 'utf8' |
features | The component features to parse and extract. |
Default features: ['name', 'description', 'keywords', 'slots', 'model', 'props', 'data', 'computed', 'events', 'methods'] |
|
loaders | Use this option to define custom loaders for specific languages |
defaultMethodVisibility | Can be set to 'public' (default), 'protected' , or 'private' |
ignoredVisibilities | List of ignored visibilities. Default: ['protected', 'private'] |
stringify | Set to true to disable parsing of literal values and stringify literal values. Default: false |
名称 | 描述 |
---|---|
文档名称 | 要解析的文件名。 必需的 ,除非filecontent 传递 |
文件内容 | 要解析的文件内容。 除非传递filename 否则为必需 |
编码方式 | 文件编码。 默认为'utf8' |
特征 | 该组件具有解析和提取功能。 |
默认功能: ['name', 'description', 'keywords', 'slots', 'model', 'props', 'data', 'computed', 'events', 'methods'] |
|
装载机 | 使用此选项可以为特定语言定义自定义加载程序 |
defaultMethodVisibility | 可以设置为'public' ( 默认 ), 'protected' 或'private' |
被忽略的可能性 | 忽略的可见性列表。 默认值: ['protected', 'private'] |
串化 | 设置为true 将禁用对文字值的解析并对文字值进行字符串化。 默认值: false |
Note for stringify
option
注意stringify
选项
By default Vuedoc Parser parses literal values defined in the source code. This means:
默认情况下,Vuedoc Parser解析源代码中定义的文字值。 这表示:
const binVar = 0b111110111 // will be parsed as binVar = 503
const numVar = 1_000_000_000 // will be parsed as numVar = 1000000000
To preserve literal values, set the stringify
option to true
.
要保留文字值,请将stringify
选项设置为true
。
用法 (Usage)
See test/fixtures/checkbox.vue for an Vue Component decoration example.
有关Vue组件装饰示例,请参见test / fixtures / checkbox.vue 。
const Vuedoc = require('@vuedoc/parser')
const options = {
filename: 'test/fixtures/checkbox.vue'
}
Vuedoc.parse(options)
.then((component) => console.log(component))
.catch((err) => console.error(err))
This will print this JSON output:
这将打印此JSON输出:
{
"name": "checkbox" // The component name