Coder Social home page Coder Social logo

twkun / apidoc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from caixw/apidoc

0.0 1.0 0.0 702 KB

RESTful API 文档生成工具,支持 Go、Java、Swift、Javascript、Rust、Python 和 Ruby 等大部分语言。

Home Page: http://apidoc.tools

License: MIT License

Go 87.47% Groovy 0.81% Java 0.75% JavaScript 1.83% Pascal 0.66% Perl 0.61% PHP 0.68% Python 0.64% Ruby 0.62% Rust 0.77% Swift 0.71% HTML 3.16% CSS 1.28%

apidoc's Introduction

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 文件中找到。

apidoc's People

Contributors

caixw 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.