Ruby-on-rails 如何为控制器自动生成 Rails REST API 文档?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/973390/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 21:20:20  来源:igfitidea点击:

How to auto generate Rails REST API documentation for controllers?

ruby-on-railsrestdocumentation

提问by Teo Choong Ping

How to automatically generate API documentation for Rails REST controller?

如何为 Rails REST 控制器自动生成 API 文档?

Is there any example I can look into using RDoc to do this?

有没有我可以研究使用 RDoc 来做到这一点的例子?

回答by Pavel

You can try apipie-railswhich I created: https://github.com/Pajk/apipie-rails/

你可以试试apipie-rails我创建的:https: //github.com/Pajk/apipie-rails/

It can do more things than just generate documentation, more info on https://github.com/Pajk/apipie-rails/.

它可以做更多的事情,而不仅仅是生成文档,更多信息请访问https://github.com/Pajk/apipie-rails/

回答by glamouracademy

I found https://github.com/zipmark/rspec_api_documentationto be a really nice tool. It's driven off of rspec acceptance tests so you're writing documentation at the same time you're writing acceptance tests! Double win!

我发现https://github.com/zipmark/rspec_api_documentation是一个非常好的工具。它脱离了 rspec 验收测试,因此您在编写验收测试的同时编写文档!双赢!

回答by Dida

Use rapi_docgem. The setup is very simple and straight forward. Follow this tutorial: http://www.rubyglob.com/generating-api-documentation-with-rapi_doc/

使用rapi_docgem。设置非常简单直接。按照本教程:http: //www.rubyglob.com/generating-api-documentation-with-rapi_doc/

回答by Mehrez

You can use "calamum" a ruby build program to generate a nice html api doc from yaml file definition. https://github.com/malachheb/calamum

您可以使用“calamum” ruby​​ 构建程序从 yaml 文件定义生成一个漂亮的 html api 文档。 https://github.com/malachheb/calamum

回答by Sebastialonso

Although is not automatic, I define and document my APIs using RESTful API Modeling Language or, RAML.

虽然不是自动的,但我使用 RESTful API 建模语言或RAML定义和记录我的 API 。

There are Node.js packages that turn the yaml file into a nice looking html documentation, like raml2html.

有一些 Node.js 包可以将 yaml 文件变成一个漂亮的 html 文档,比如raml2html

回答by Ameen

I was also searching for a good documentation tool which can be easily integrated into rails. Finally we built our own rails engine APIDOCO

我也在寻找一个很好的文档工具,它可以很容易地集成到 rails 中。最后我们构建了自己的 Rails 引擎APIDOCO

However it does not auto generate the documentation but you can easily use it.

但是它不会自动生成文档,但您可以轻松使用它。