5.1.0 • Published 3 years ago

@youngjuning/interface-comments-parser v5.1.0

Weekly downloads
1
License
MIT
Repository
-
Last release
3 years ago

@youngjuning/interface-comments-parser

WIP: This is an initial draft, API is not stable

NPM version build status Test coverage

$ 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;
  };
}

API

parse(filePath: string, name: string): IField[];

getFieldMeta(field: IField, language?: string): IMeta;

5.1.0

3 years ago

5.0.0

3 years ago

3.4.0

3 years ago

3.5.0

3 years ago

4.0.0

3 years ago

3.3.4

3 years ago

3.3.3

3 years ago

3.3.2

3 years ago

3.3.1

3 years ago

3.3.0

3 years ago

3.2.1

3 years ago

3.2.0

3 years ago

3.1.0

3 years ago

3.0.0

3 years ago

1.0.0

3 years ago