Skip to content

Commit

Permalink
Add missing RDoc::RubygemsHook API for gem server (#1270)
Browse files Browse the repository at this point in the history
This PR fixes #1269.

## Expected Behavior

`gem server` command is successful.

```console
$ gem server
Server started at http://[::]:8808
Server started at http://0.0.0.0:8808
```

http://127.0.0.1:8808/ works.

## Actual Behavior

`gem server` command doesn't work because `Gem::RDoc.load_rdoc` raises
`NoMethodError`.

```console
$ gem server
ERROR:  While executing gem ... (NoMethodError)
    undefined method 'load_rdoc' for class RDoc::RubygemsHook

    Gem::RDoc.load_rdoc
             ^^^^^^^^^^
        /Users/mterada/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/rubygems-server-0.3.0/lib/rubygems/server.rb:437:in 'Gem::Server#initialize'
        /Users/mterada/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/rubygems-server-0.3.0/lib/rubygems/server.rb:426:in 'Class#new'
        /Users/mterada/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/rubygems-server-0.3.0/lib/rubygems/server.rb:426:in 'Gem::Server.run'
        /Users/mterada/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/rubygems-server-0.3.0/lib/rubygems/commands/server_command.rb:83:in 'Gem::Commands::ServerCommand#execute'
        /Users/mterada/.rbenv/versions/3.4.1/lib/ruby/3.4.0/rubygems/command.rb:326:in 'Gem::Command#invoke_with_build_args'
        /Users/mterada/.rbenv/versions/3.4.1/lib/ruby/3.4.0/rubygems/command_manager.rb:253:in 'Gem::CommandManager#invoke_command'
        /Users/mterada/.rbenv/versions/3.4.1/lib/ruby/3.4.0/rubygems/command_manager.rb:194:in 'Gem::CommandManager#process_args'
        /Users/mterada/.rbenv/versions/3.4.1/lib/ruby/3.4.0/rubygems/command_manager.rb:152:in 'Gem::CommandManager#run'
        /Users/mterada/.rbenv/versions/3.4.1/lib/ruby/3.4.0/rubygems/gem_runner.rb:57:in 'Gem::GemRunner#run'
        /Users/mterada/.rbenv/versions/3.4.1/bin/gem:12:in '<main>'
```

## Versions

```console
$ rdoc -v
6.10.0
```

---------

Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
  • Loading branch information
mterada1228 and kou authored Jan 7, 2025
1 parent a047068 commit b6a8224
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/rdoc/rubygems_hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -310,5 +310,21 @@ def self.generation_hook installer, specs
# Generate document for compatibility if this is a default gem.
RubyGemsHook.generate(installer, specs)
end

def self.load_rdoc
RubyGemsHook.load_rdoc
end

def self.rdoc_version
RubyGemsHook.rdoc_version
end

def rdoc_installed?
RubyGemsHook.new(@spec).rdoc_installed?
end

def ri_installed?
RubyGemsHook.new(@spec).ri_installed?
end
end
end

0 comments on commit b6a8224

Please sign in to comment.