6. Generating Documentation
6.1 Generating Documentation with RDoc
RDoc is the documentation generator distributed with Ruby. It automatically extracts documentation from source files in Ruby, C, C++, and Fortran. But it doesn’t read Objective-C. Here’s a quick hack to make it do so.
First, find the rdoc/parsers/parse_c.rb file on your system. Mine’s in /usr/lib/ruby. Then edit it, and search for a line like this:
parse_files_matching(/\.(c|cc|cpp|CC)$/)
Add “m”, the Objective-C extension, to the regular expression. I also added “mm” for Objective-C++.
parse_files_matching(/\.(m|mm|c|cc|cpp|CC)$/)
That was quick and easy, but it felt a bit dirty to hack the Ruby distribution. Does anyone have time to work out a better way? How about a patch for Ruby?
UPDATE: Here’s a patch script that I used to fix a fresh Leopard installation. It should also work on older systems.#!/bin/sh patch /usr/lib/ruby/1.8/rdoc/parsers/parse_c.rb <<END 170c170 < parse_files_matching(/\.(c|cc|cpp|CC)$/) --- > parse_files_matching(/\.(c|cc|cpp|CC|m|mm)$/) END
Did you find an error? Is something missing? Post your comment or suggestion below!
Comments (0) post