Skip to content

MixinHandler erroneously attaching module to root namespace #1386

@dduugg

Description

@dduugg

Hi, I have a yard plugin, wherein one module is included in another, like so:

YARD::Handlers::Ruby::ClassHandler.include YARDSorbet::StructClassHandler

(this may be a suboptimal design, feedback welcome.)

This should register YARDSorbet::StructClassHandler's methods under the YARD::Handlers::Ruby::ClassHandler namespace. Instead, what I'm finding is that the methods are instead registered on the top-level namespace.

Poking around a bit, I think there might be an unhandled case in YARD::Handlers::Ruby::MixinHandler#recipient, where if statement[0].type is a :const_path_ref, the recipient should be a code object representing statement[0], instead of the current namespace.

Let me know if that sounds right, and if you have any advice for resolution (I realize I can open up the class to resolve this specific case, but it still produces erroneous output for non-DSL usage).

Update: I've written a workaround, so this is no longer visible in the online documentation, but can be repro'd by checking out at 209737c and running rake yard.

Thanks!

Steps to reproduce

git clone https://github.com/dduugg/yard-sorbet.git
cd yard-sorbet
bundle exec yard doc

Environment details:

  • OS: [Enter operating system / version here]
  • Ruby version (ruby -v): 2.7.2
  • YARD version (yard -v): 0.9.26
  • Relevant software dependency/versions:
    • [Any 3rd party libs required to reproduce, omit if none]

I have read the Contributing Guide.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions