Rdoc bug with 'class M::C' syntax

I wonder if anyone else has seen this with the recent CVS of Rdoc. It
wasn’t happening as recently as 28 May 2003, but with the 23 Sep 2003
CVS, using M::C when M is in a required file causes a problem.

==== a.rb ====
require ‘./m’

module M; end # this prevents the problem

class M::C
def foo; end
end

···

==============

==== b.rb ====
module M; end

The rdoc commands I tried are:

$ rdoc b.rb a.rb

                            b.rb: m
                            a.rb: c

a.rb:4:9: Couldn’t find module M
/usr/local/lib/ruby/site_ruby/1.8/rdoc/parsers/parse_rb.rb:1737:in
parse_class': undefined methodadd_class’ for nil:NilClass (NoMethodError)

$ rdoc a.rb b.rb

                            a.rb: c

a.rb:4:9: Couldn’t find module M
/usr/local/lib/ruby/site_ruby/1.8/rdoc/parsers/parse_rb.rb:1737:in
parse_class': undefined methodadd_class’ for nil:NilClass (NoMethodError)

Both of these work fine with the older CVS.

In the past, RDoc didn’t bother to look for the actual definition of
modules, but now it does. However, it also does not actually execute
your program, so it doesn’t perform the require, and hence doesn’t load
up module ‘M’ before you then use it later in the code.

There are two fixes: in the short term, simply put the file containing
the definition of M earlier in the command line to RDoc. When I get a
chance I’ll fix RDoc to dummy up the module M in this case
automatically.

Cheers

Dave

···

On Saturday, Oct 4, 2003, at 16:37 US/Central, Joel VanderWerf wrote:

I wonder if anyone else has seen this with the recent CVS of Rdoc. It
wasn’t happening as recently as 28 May 2003, but with the 23 Sep 2003
CVS, using M::C when M is in a required file causes a problem.

==== a.rb ====
require ‘./m’

module M; end # this prevents the problem

Dave Thomas wrote:

I wonder if anyone else has seen this with the recent CVS of Rdoc. It
wasn’t happening as recently as 28 May 2003, but with the 23 Sep 2003
CVS, using M::C when M is in a required file causes a problem.

==== a.rb ====
require ‘./m’

module M; end # this prevents the problem

In the past, RDoc didn’t bother to look for the actual definition of
modules, but now it does. However, it also does not actually execute
your program, so it doesn’t perform the require, and hence doesn’t load
up module ‘M’ before you then use it later in the code.

Actually, I had the same problem with either order of the two files. It
didn’t help to see the file containing the definition of M first.

I’m happy with the older version, for now. Thanks!

···

On Saturday, Oct 4, 2003, at 16:37 US/Central, Joel VanderWerf wrote: