rdoc icon indicating copy to clipboard operation
rdoc copied to clipboard

Double class name before the top-level constant

Open gemmaro opened this issue 5 years ago • 1 comments

Here's a minimal example:

$ exa -T
.
└── lib
   └── main.rb
# lib/main.rb
def aaa
  BBB ::CCC
end

And then I run RDoc ($ rdoc).

In the generated HTML, there is a doubling of the class that is placed before the top-level constant. The "top-level constant" here refers to the one at this link: https://docs.ruby-lang.org/en/master/doc/syntax/modules_and_classes_rdoc.html#label-Constants

Screenshot_2020-09-27 class Object - RDoc Documentation(2)

This doesn't happen if the constant is enclosed in parentheses.

Here's a case that seems more likely to be real: Pathname ::ENV['HOME']

Using RDoc 6.2.1.

gemmaro avatar Sep 27 '20 04:09 gemmaro

I reproduced it with below:

class Foo
  def bar
    Pathname ::ENV['HOME']
  end
end

Then:

def bar
  PathnamePathname::ENV['HOME']
end

And when I removed :: from ::ENV,

class Foo
  def bar
    Pathname ENV['HOME']
  end
end

The problem is resolved:

def bar
  Pathname ENV['HOME']
end

I suspect it's caused by a parser. I'll look into it.

okuramasafumi avatar May 25 '24 13:05 okuramasafumi