17.1. Using RDoc

RDoc isn’t the only doc tool around for Ruby; RDTOOL is older. But in many ways, RDoc is superior; it’s also more commonly used, at least in the United States.

One great thing about RDoc is that it tries to produce useful output even if there are no comments in the source. It does this by parsing the code and organizing information on all the classes, module, constants, methods, and so on.

Therefore you can get reasonably useful HTML out of a program source that doesn’t even have any real internal documentation. If you haven’t tried this before, I suggest you try it.

But it gets better. RDoc also tries to associate the comments it finds with specific parts of the program. The general rule is: A block comment preceding a definition ...

Get The Ruby Way: Solutions and Techniques in Ruby Programming, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.