Search code examples
rubyrdoc

Syntax highlight Ruby code in RDoc file?


I am documenting a Ruby library I am writing. In my README.rdoc file, I am including an example of the usage with some demo Ruby code.

However, the resulting HTML documentation does not show the Ruby code with syntax highlighting, merely as a block of code.

When I look at the source of e.g. http://rdoc.rubyforge.org/README_rdoc.html, all I see is a piece of Ruby code, just like I included in my README.rdoc. Is there a special option to pass to the rdoc command?


Solution

  • You must use an RDoc template that includes syntax highlighting. There are many floating around the web.

    (I agree with Phrogz, you should use YARD and also the Markdown syntax.)