开发者

How can I document implicit methods inside of rails models?

开发者 https://www.devze.com 2022-12-30 23:34 出处:网络
I\'m using YARD on my Rails project and was wondering how I would go about documen开发者_JS百科ting inherited/runtime methods on a Rails model? For instance documenting the existence of a first_name a

I'm using YARD on my Rails project and was wondering how I would go about documen开发者_JS百科ting inherited/runtime methods on a Rails model? For instance documenting the existence of a first_name attribute on a User model.


You can't do that, IMHO.

The trouble is that those methods don't really "exist"; They are "created on the fly" via method_missing hooks, the first time they are invoked, on runtime.

Other documentation generation systems have ways to declare "implicit" methods. For example NaturalDocs has a function keyword that allows you to create functions that only exist on the comments. I'm not familiar enough with YARD, but it seems it doesn't have a similar functionality.

Good luck!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号