views:

106

answers:

2

I'm using some meta-programming to generate a bunch of methods in ruby like so:

class EmotionalObject
  def self.mood( name, *details )
    define_method(name) do
      # ...
    end
  end

  mood :happy, #...
  mood :sad, #...
  mood :ebuillent, #...
  #...
 end

I know that I can pass rdoc '-A mood' to get it to recognize my mood generation code as attributes, which is handy, since then they at least get recognized.

However, they're really more like regular methods than attributes, so I don't want them listed under the 'Attributes:' section when I look at the documentation using ri. I don't have any regular attributes, so is there any simple way I can just change the title of this section to be 'Moods:' or something like that, so my users are at least curious enough to type ri EmotionalObject#happy.

+1  A: 

It's hardcoded into the RDoc templates, but you can make a new template to use by duplicating the default "html" template and changing the heading name by hand.

See the RDoc template source here: http://github.com/juretta/ruby/blob/master/lib/rdoc/generator/html/html.rb#L601.

Ben Alpert
+1  A: 

It appears that somewhere around rdoc 2.4.1 they removed --accessor and replaced it with using ## comments on each meta-method. While this allows you to get them out of the attributes section, it also forces you to comment each one individually.

http://rdoc.rubyforge.org/RDoc/Parser/Ruby.html

Justin Love
Awesome! This is good news!
rampion