RDoc: change the name of the "Attributes:" section in the ri documentation

I use metaprogramming to create a bunch of methods in ruby, for example:

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

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

      

I know I can go through the rdoc

'-A mood' to find out its generating mood as attributes, which is handy since then they will at least find out.

However, they look more like regular methods than attributes, so I don't want them to be listed under "Attributes:" when I look in the documentation with ri

. I don't have any normal attributes, so there is an easy way, I can just change the title of this section to be "Mood:" or something, so my users are at least curious enough to type ri EmotionalObject#happy

.

+1


source to share


2 answers


It is hardcoded into RDoc templates, but you can create a new template by duplicating the default "html" template and manually changing the title name.



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

+1


source


It seems like somewhere around rdoc 2.4.1 they removed --accessor

and replaced it with using ##

comments for each meta method. While this allows you to take them out of the attributes section, it also forces you to comment out each one separately.



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

+1


source







All Articles