Giter Club home page Giter Club logo

gendoc's Introduction

gendoc

文档生成工具

MarkDown生成说明

示例

// doc是字段说明
// 如果是必填項,doc里填写 required 即可,注意required前面需要加空格
type ReqCreateOrder struct {
	Pass       string  `json:"pass" doc:"交易密码不能为空,请用BASE64 进行转码 required"`
	Amount     float32 `json:"amount" doc:"支付金额,不能小于或等于0"`
	RandomNum  string  `json:"randomNum" doc:"随机字符串不能为空,最大长度为30"`
	TranBody   string  `json:"tranBody" doc:"交易描述不能为空,最大长度为30;"`
	OutTradeNo string  `json:"outTradeNo" doc:"三方交易唯一订单号,最大长度60"`
	CreateIp   string  `json:"createIp" doc:"IP地址"`
	StartTime  int64   `json:"startTime" doc:"交易开始时间搓,格式为yyyyMMddHHmmss"`
}

type RespCreateOrder struct {
	Code int32       `json:"code" doc:"错误码"`
	Msg  string      `json:"msg" doc:"错误信息"`
	Data interface{} `json:"data" doc:"业务数据"`
}


func TestGenMarkDown(t *testing.T) {
	// 实例化文档
	doc := &gendoc.Document{
		Title:   "接口文档",
		Version: "v1.0.0",
		BaseUrl: "http://127.0.0.1:8080",
	}
	// 添加接口
	doc.AddItem("创建订单接口", "/v1/order/create", gendoc.POST, gendoc.Tomas, &ReqCreateOrder{}, &RespCreateOrder{Data: &ReqCreateOrder{}})
	// 生成字段
	doc.GenerateFields()
	// 实例化文档生成器
	md := New(doc)
	// 生成文档
	md.Generate("./doc.md")
}

demo

gendoc's People

Contributors

w3liu avatar

Watchers

 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.