# @hzzlyxx/ts-docs

> TS接口类型转换为json对象

Latest version **1.1.0** (published 2021-10-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @hzzlyxx/ts-docs
pnpm add @hzzlyxx/ts-docs
yarn add @hzzlyxx/ts-docs
bun add @hzzlyxx/ts-docs
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2021-10-21 |
| First published | 2021-08-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 15.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | hzzly |
| Maintainers | hzzly |
| Keywords | TypeScript, ts2json, json2markdown, esm2json |

## Links

- npm: https://www.npmjs.com/package/@hzzlyxx/ts-docs
- Repository: https://github.com/hzzlyxx/docs
- Issues: https://github.com/hzzlyxx/docs/issues
- npm.io page: https://npm.io/package/@hzzlyxx/ts-docs

## Dependencies (4)

- [prettier](https://npm.io/package/prettier.md) ^2.3.2
- [typescript](https://npm.io/package/typescript.md) ^4.3.5
- [@babel/parser](https://npm.io/package/@babel/parser.md) ^7.15.8
- [@babel/traverse](https://npm.io/package/@babel/traverse.md) ^7.15.4

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.1.0 (latest) — 2021-10-21
- 1.0.10 — 2021-09-08
- 1.0.9 — 2021-08-25
- 1.0.8 — 2021-08-25
- 1.0.7 — 2021-08-25
- 1.0.6 — 2021-08-25
- 1.0.5 — 2021-08-11
- 1.0.4 — 2021-08-11
- 1.0.3 — 2021-08-08
- 1.0.2 — 2021-08-08
- 1.0.1 — 2021-08-08

## README

## @hzzlyxx/ts-docs

![NPM version](https://img.shields.io/npm/v/@hzzlyxx/ts-docs)
![NPM download](https://img.shields.io/npm/dt/@hzzlyxx/ts-docs)

### How to use

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

### Examples

```ts
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 接口定义

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

### 转换为 json 对象

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

### 生成 MarkDown

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

---
_Source: https://npm.io/package/@hzzlyxx/ts-docs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
