🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@hzzlyxx/ts-docs

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hzzlyxx/ts-docs

TS接口类型转换为json对象

1.1.0
latest
Source
npm
Version published
Maintainers
1
Created
Source

@hzzlyxx/ts-docs

NPM version NPM download

How to use

npm install @hzzlyxx/ts-docs --save
// or
yarn add @hzzlyxx/ts-docs

Examples

import * as fs from "fs";
import { TsToJson, JsonToMarkdown } from "@hzzlyxx/ts-docs";

const ts2Json = new TsToJson();
const json2Markdown = new JsonToMarkdown();
const json = ts2Json.parse("./type.ts"); // fileName 文件路径
fs.writeFileSync(
  path.join(dir, `./index.md`),
  json2Markdown.commentToMarkDown(json)
);

TypeScript 接口定义

// type.ts
/**
 * @name Button
 * @description 按钮组件
 */
export interface ButtonProps {
  /**
   * @description Button 类型
   */
  htmlType?: "button" | "submit" | "reset";
  ...
}

转换为 json 对象

{
  "Button": {
    "description": "按钮组件",
    "props": [
      {
        "name": "htmlType",
        "type": "\"button\" | \"submit\" | \"reset\"",
        "default": "",
        "description": "Button 类型",
        "required": false
      }
      ...
    ]
  }
}

生成 MarkDown

属性描述类型默认值必填
htmlTypeButton 类型"button" | "submit" | "reset"--

Keywords

TypeScript

FAQs

Package last updated on 21 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts