Giter Site home page Giter Site logo

api-generate's Introduction

TSX组件文档生成

使用TypeScript开发React组件时,定义组件的属性类型,并且配合JS Doc注解,就可以自动生成组件属性API文档。

DEMO演示

基础组件

import * as React from "react";
import { Component } from "react";

/**
 *  BaseComponent properties.
 */
export interface IBaseComponentProps {
  /** 属性一*/
  prop1?: string;
  /** 属性二 */
  prop2: number;
  /**属性三*/
  prop3: () => void;
  /** 属性四 */
  prop4: "option1" | "option2" | "option3";
}

/**
 * BaseComponent
 */
export class BaseComponent extends Component<IBaseComponentProps, {}> {
  render() {
    return <div>BaseComponent</div>;
  }
}

API文档

# 组件

## 参数 Props

| 参数  | 说明   | 类型                                                                | 默认值 | 必填  |
| ----- | ------ | ------------------------------------------------------------------- | ------ | ----- |
| prop1 | 属性一 | string                                                              | -      | false |
| prop2 | 属性二 | number                                                              | -      | true  |
| prop3 | 属性三 | () => void                                                          | -      | true  |
| prop4 | 属性四 | "option1" &nbsp;&#124;&nbsp; "option2" &nbsp;&#124;&nbsp; "option3" | -      | true  |

操作

在对应的文件下,或者在侧边栏文件名上右击,选择「组件API文档生成」,即可自动生成组件属性API文档,并自动复制到粘贴板,用户直接到对应文件粘贴即可。

api-generate's People

Contributors

honorsuper avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.