rdoc icon indicating copy to clipboard operation
rdoc copied to clipboard

RDoc::Mixin needs module nesting information

Open tompng opened this issue 10 months ago • 0 comments

This two include M are not the same.

class A::B
  # A::B.include(M) with Module.nesting == [A::B]
  include M
end

class A
  class B
    # A::B.include(M) with Module.nesting == [A::B, A]
    include M
  end
end

RDoc::Mixin needs information of module nesting for correct module name lookup.

Currently, RDoc uses CodeObject#parent to represent module nesting but it changes while parsing. Resolving module name of include/extend is done after all files are parsed. It is incorrect because it might be overwritten while parsing another file. We need something like RDoc::Mixin#module_nesting.

class A::B
  # parent of A::B is TopLevel
  include M
end

class A
  class B
    # parent of A::B changes to A
  end
end

tompng avatar Feb 11 '25 17:02 tompng