Search code examples
rubymetaprogrammingrdocri

RDoc : Change name of 'Atttributes:' section in ri-documentation


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.


Solution

  • 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.