ruby / ruby/rdoc

Problem due to commit 75d15117643d17a3c3d92b41512bd7840c91705b included with 6.12.0

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

Nobody has claimed this yet.

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

Description

First of all, I should add that this is not really a bug, more of an uncomfortable compatibility problem, but README encourages me to report anything I have a problem with (nice, thanks!), so here's the problem:

I have a project which inherits from RDoc::Parser::C to generate documention for its ruby bindings.

module RDoc

    class C_Parser_Paludis < Parser::C
        #override C_Parse
        parse_files_matching(/\.(c|cc|cpp|CC)$/)

        def initialize(top_level, file_name, body, options, stats)
            ...
            super(top_level, file_name, new_body, options, stats)
        end
    ...
    end
end
begin
    r = RDoc::RDoc.new
    r.document(ARGV)
rescue RDoc::Error => e
    $stderr.puts e.message
    exit(1)
end

(Full code here: https://gitlab.exherbo.org/paludis/paludis/-/blob/master/doc/api/ruby/create_ruby_doc.rb)

After updating ruby 3.4.4 to 3.4.5, which updated rdoc from 6.10.0 to 6.14.0 I get:

RDoc is not a full Ruby parser and will fail when fed invalid ruby programs.

The internal error was:

        (ArgumentError) wrong number of arguments (given 4, expected 5)

/home/heiko/Quelltexte/git-sources/exherbo/paludis/doc/api/ruby/create_ruby_doc.rb:13:in 'initialize': wrong number of arguments (given 4, expected 5) (ArgumentError)
        from /usr/x86_64-pc-linux-gnu/lib/ruby/3.4/rdoc/parser.rb:194:in 'Class#new'
        from /usr/x86_64-pc-linux-gnu/lib/ruby/3.4/rdoc/parser.rb:194:in 'RDoc::Parser.for'
        from /usr/x86_64-pc-linux-gnu/lib/ruby/3.4/rdoc/rdoc.rb:350:in 'RDoc::RDoc#parse_file'
        from /usr/x86_64-pc-linux-gnu/lib/ruby/3.4/rdoc/rdoc.rb:406:in 'block in RDoc::RDoc#parse_files'
        from /usr/x86_64-pc-linux-gnu/lib/ruby/3.4/rdoc/rdoc.rb:404:in 'Array#map'
        from /usr/x86_64-pc-linux-gnu/lib/ruby/3.4/rdoc/rdoc.rb:404:in 'RDoc::RDoc#parse_files'
        from /usr/x86_64-pc-linux-gnu/lib/ruby/3.4/rdoc/rdoc.rb:467:in 'RDoc::RDoc#document'
        from /home/heiko/Quelltexte/git-sources/exherbo/paludis/doc/api/ruby/create_ruby_doc.rb:87:in '<main>'

This is "caused" by 75d15117643d17a3c3d92b41512bd7840c91705b, which changed initialize's signature. I could conditionalize the call to super(..), but I don't know how to do that for C_Parser_Paludis's initialize itself.

Any pointers how this could be best solved without requiring rdoc >= 6.12.0 would be very welcome.

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 doc/api/ruby/create_ruby_doc.rb, especially C_Parser_Paludis#initialize, and inspect the parser construction path in rdoc/parser.rb. Compare the initializer contract before and after commit 75d15117643d17a3c3d92b41512bd7840c91705b, then verify a compatibility approach that works without requiring RDoc >= 6.12. Done means the documented Ruby binding generation flow no longer raises the argument-count error across the affected RDoc versions.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.