How to add RDoc documentation for a method defined with class_eval?

I use class_eval to more class_eval describe a bunch of duplicate methods, something like this:

 %w{greasy chunky bacon}.product(%w{flying sky poodle}).each do |a,b| class_eval "def #{a}_#{b}; do_something; end" end 

I would like all the resulting methods to be included in the RDoc documentation. Is there an RDoc directive that manually adds a method to the list of methods for a class? I can not find him.

+8
ruby metaprogramming rdoc
source share
1 answer

In the RDoc documentation sections for RDoc::Parser::Ruby see the "Metaprogramming Methods and Hidden Methods and Attributes" sections.

In your case, you would do something like:

 ## # :method: greasy_flying # Makes grease fly. ## # :method: chunky_poodle # This is a really gruesome method. Ewww! 

And so on.

+6
source share

All Articles