Strange rdoc error with :section:

Hi,

I very like the new section feature of rdoc...

But when I use it with the newest version of ruby from CVS (ruby 1.9.0 (2004-11-26) [i386-dragonfly1.1]) and the following file:

   #file: rdoc-test.rb

   # :section: Test

   def test
   end

I get the following error:

> rdoc

                        rdoc-test.rb:

RDoc failure in rdoc-test.rb at or around line 3 column 0

Before reporting this, could you check that the file
you're documenting compiles cleanly--RDoc is not a
full Ruby parser, and gets confused easily if fed
invalid programs.

The internal error was:

/home/mneumann/Programs/usr/lib/ruby/1.9/rdoc/markup/simple_markup/preprocess.rb:21:in `gsub!': string modified (RuntimeError)
         from /home/mneumann/Programs/usr/lib/ruby/1.9/rdoc/markup/simple_markup/preprocess.rb:21:in `handle'
         from /home/mneumann/Programs/usr/lib/ruby/1.9/rdoc/parsers/parse_rb.rb:2287:in `look_for_directives_in'
         from /home/mneumann/Programs/usr/lib/ruby/1.9/rdoc/parsers/parse_rb.rb:1561:in `parse_toplevel_statements'

···

############################

This seems to be a very strange Ruby error.
With the following patch the problem goes away... but I really don't understand why.

===================================================================
RCS file: /var/cvs/src/ruby/lib/rdoc/markup/simple_markup/preprocess.rb,v
retrieving revision 1.3
diff -u -r1.3 preprocess.rb
--- rdoc/markup/simple_markup/preprocess.rb 19 Feb 2004 03:23:51 -0000 1.3
+++ rdoc/markup/simple_markup/preprocess.rb 25 Nov 2004 23:03:04 -0000
@@ -18,7 +18,7 @@
      # as |directive, param|

      def handle(text)
- text.gsub!(/^([ \t#]*):(\w+):\s*(.+)?\n/) do
+ text.dup.gsub!(/^([ \t#]*):(\w+):\s*(.+)?\n/) do

          prefix = $1
          directive = $2.downcase

Regards,

   Michael

Wow - I see that too. Must be some new checking added to gsub. Rather than dup the string, I think I've fixed it by simply terminating the loop early in the case where it comes across :section: (the handling is special, because I want to force the comment to appear in the section header, and not as the comment for any subsequent class or method). Anyway, the lastest CVS should fix it (but I'd appreciate any feedback).

Cheers

Dave

···

On Nov 25, 2004, at 17:05, Michael Neumann wrote:

I very like the new section feature of rdoc...

But when I use it with the newest version of ruby from CVS (ruby 1.9.0 (2004-11-26) [i386-dragonfly1.1]) and the following file:

RDoc failure in rdoc-test.rb at or around line 3 column 0