Rails控制器文档是最佳实践吗?(Is Rails controller documentation a best practice? [closed])

编程入门 行业动态 更新时间:2024-10-23 22:33:47
Rails控制器文档是最佳实践吗?(Is Rails controller documentation a best practice? [closed])

Reek gem在我的代码中识别出一种气味,因此它缺少类中的文档。 但我想知道是否应该也应用于控制器。

在良好的代码库中,控制器将非常薄,只需处理请求并将所有逻辑委托给模型/服务/帮助程序。 因此,开始记录并不多。 不是API,特别是不是开放的API,我没有看到向它添加文档的充分理由。

想听听你对此的看法。

Reek gem identifies a smell in my code such that it lacks documentation in classes. But I was wondering if that should be applied to controllers as well.

In a good codebase, a controller would be very thin, just dealing with the requests and delegating all the logic to models/services/helpers. Hence not much to document to begin with. Not being an API and especially not an open one, I don't see a good reason to add documentation to it.

Would like to hear your opinion on this.

最满意答案

在我看来,控制器中不需要文档。 但是如果你想让臭味不能识别这种气味,那么你可以添加一个控制器的单线解释或添加

#:nodoc: all

在控制器的顶部(这就是我所做的)。 这是由rubycop gem建议的

希望这可以帮助。

In my opinion, there is no need for documentation in controllers. But if you want reek to not identify this smell then you can add a one-liner explanation of the controller or add

#:nodoc: all

at the top in your controllers (this is what I do). This is suggested by rubycop gem

Hope this helps.

更多推荐

本文发布于:2023-08-01 11:23:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1357946.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控制器   文档   Rails   controller   closed

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!