apidoc

command module
v0.0.0-...-3fc9e9f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2017 License: MIT Imports: 22 Imported by: 0

README

apidoc Build Status

apidoc 是一个简单的 RESTful API 文档生成工具,它从代码注释中提取特定格式的内容,生成文档。 目前支持支持以下语言:C#、C/C++、D、Erlang、Go、Groovy、Java、Javascript、Pascal/Delphi、 Perl、PHP、Python、Ruby、Rust、Scala 和 Swift。

具体文档可参考:http://apidoc.tools

/**
 * @api get /users 获取所有的用户信息
 * @apiGroup users
 * @apiQuery page int 显示第几页的内容
 * @apiQuery size int 每页显示的数量
 *
 * @apiSuccess 200 ok
 * @apiParam count int 符合条件的所有用户数量
 * @apiParam users array 用户列表。
 * @apiExample json
 * {
 *     "count": 500,
 *     "users": [
 *         {"id":1, "username": "admin1", "name": "管理员2"},
 *         {"id":2, "username": "admin2", "name": "管理员2"}
 *     ],
 * }
 * @apiExample xml
 * <users count="500">
 *     <user id="1" username="admin1" name="管理员1" />
 *     <user id="2" username="admin2" name="管理员2" />
 * </users>
 */
func login(w http.ResponseWriter, r *http.Request){
    // TODO
}
安装
go get github.com/caixw/apidoc
集成

若需要将 apidoc 当作包集成到其它 Go 程序中,可分别引用 inputoutput 的相关函数:

start := time.Now()
docs := doc.New()

tag, err := locale.GetLocale()
if err != nil {
    panic(err)
}
locale.SetLocale(tag)

// 分析文档内容
inputOptions := &input.Options{...}
docs, err := input.Parse(docs, inputOptions)
if err != nil {
    // TODO
}

// 输出内容
outputOptions := &output.Options{...}
outputOptions.Elapsed = time.Now().Sub(start)
if err = output.Render(docs, outputOptions); err != nil {
    // TODO
}
参与开发

请阅读 CONTRIBUTING.md 文件的相关内容。

版权

本项目采用 MIT 开源授权许可证,完整的授权说明可在 LICENSE 文件中找到。

Documentation

Overview

apidoc 是一个 RESTful API 文档生成工具。

Directories

Path Synopsis
app 提供了一些公共的函数、结构体及代码级别的设置项。
app 提供了一些公共的函数、结构体及代码级别的设置项。
doc 包含了对文档各个结构的定义及对注释块的解析。
doc 包含了对文档各个结构的定义及对注释块的解析。
docs
input 用于处理文件输入,过滤代码,生成 doc.Doc 数据。
input 用于处理文件输入,过滤代码,生成 doc.Doc 数据。
locale 提供了一个本地化翻译服务。
locale 提供了一个本地化翻译服务。
output 对解析后的数据进行渲染输出。
output 对解析后的数据进行渲染输出。
static
默认模板
默认模板

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL