Adding RDoc to Ruby Code
RDoc parses Ruby source files to extract the major elements (such as classes, modules, methods, attributes, and so on). You can choose to associate additional documentation with these by simply adding a comment block before the element in the file.
One of the design goals of RDoc was to leave the source code looking totally natural. In most cases, you don’t need any special markup in your code to get RDoc to produce decent looking documentation. For example, comment blocks can be written fairly naturally:
| # Calculate the minimal-cost path though the graph using Debrinkski's algorithm, |
| # with optimized inverse pruning of isolated leaf nodes. |
| def calculate_path |
| . . . |
| end |
You can also use Ruby’s block-comments ...
Get Programming Ruby 3.3 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.