On Jan 13, 2008, at 20:35 PM, Phlip wrote:
> Eric Hodel wrote:
>> To have RDoc parse a chunk of ruby, call RDoc::RubyParser#scan.   
>> This will fill in the RDoc::TopLevel object you provide, but I  
>> don't know how to pull the source back out.  Hunting through  
>> RDoc::Generator::HTML might help there.
>
> This is how far I got on the technical side:
>
>  def test_ruby_parser
>    top_level = RDoc::TopLevel.new(__FILE__)
>    options = Options.instance
>    parser = RDoc::RubyParser.new(top_level, 'file',  
> 'muther :luvver', options, 0)
>    file_info = parser.scan
>    gen = Generators::HTMLGenerator.for(options)
> #pp file_info
> #doc gen
> #puts    gen.generate([file_info])
> #p gen.markup
>  end  #  hence /usr/lib/ruby/1.8/rdoc/generators/html_generator.rb

You shouldn't need to use the HTML generator at all, look in  
#build_method_detail_list to see where the source code comes out the  
other side.  You should be able to follow up the call chain to figure  
out how to get to one of these sections.

>> You may have to wrap your source up in some method, too.
>
> That would seem follow from RDoc disregards top-level statements!
>
> Now, shouldn't RDoc have some unit tests, showing how to call its  
> interfaces?

If you're writing the patches, I'll apply them.