ruby / ruby/rdoc

Including modules creates an infinite loop between methods

Open
#1,088 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Ruby
Stars
930
Forks
465
Avg merge
3d 10h
Merged PRs (30d)
27

Description

Hi! I think RDoc sometimes wrongly infers module ancestry and then methods can have cyclical see references.

I encountered this error in the docs for GrpahQL-Ruby (fix: https://github.com/rmosolgo/graphql-ruby/pull/4819) and I created this script to replicate it:

# rdoc_bug.rb
module DoSomething
  def self.generate_module
    Module.new do
      include DoSomethingExtra
    end
  end

  def do_something
    1 + 1
  end

  module DoSomethingExtra
    include DoSomething

    def do_something
      super + 1
    end
  end
end

For me, that script ends in "stack level too deep":

$ rdoc rdoc_bug.rb
Parsing sources...
100% [ 1/ 1]  rdoc_bug.rb

Generating Darkfish format into /Users/rmosolgo/code/graphql-ruby/doc...
uh-oh! RDoc had a problem:
stack level too deep

run with --debug for full backtrace

I was able to work around it, so this bug is not blocking me, but I thought I'd open it here in case its helpful to anyone else.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied rdoc_bug.rb reproducer and run rdoc rdoc_bug.rb; use --debug to trace the recursive documentation path. Inspect the ancestry and method cross-reference handling involved in the cyclical see references, and consider the issue done when this example completes without a stack overflow while preserving the generated documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.