@youngjuning/interface-comments-parser
v5.1.0
Published
parser typescript interface comments
Downloads
5
Readme
@youngjuning/interface-comments-parser
WIP: This is an initial draft, API is not stable
$ yarn add -D @youngjuning/interface-comments-parser
Usage
Parse
You can use parse
to parse file.
const path = require("path");
const { parse } = require("@youngjuning/interface-comments-parser");
parse(path.resolve(__dirname, "./demo.ts"), "DemoProps");
GetFieldMeta
const path = require("path");
const { parse, getFieldMeta } = require("@youngjuning/interface-comments-parser");
const result = parse(path.resolve(__dirname, "./demo.ts"), "DemoProps");
const meta = result.map(o => getFieldMeta(o, "zh-CN"));
Type
export interface IField {
/**
* @language en-US
* @description name of fields
*/
/**
* @language zh-CN
* @description 字段名
*/
name: string;
/**
* @language zh-CN
* @description 字段是否可选(即有没有问号)
*/
optional: string;
/**
* @language zh-CN
* @description 字段类型
*/
types: string;
/**
* @language zh-CN
* @description 字段信息,用户备注。
*/
meta?: IFieldMeta;
}
export interface IMeta {
[key: string]: string;
}
export interface IFieldMeta {
base: IMeta;
i18n: {
[language: string]: IMeta;
};
}