Skip to content

Commit

Permalink
[ruby/rdoc] Finalize RDoc::Options before calling
Browse files Browse the repository at this point in the history
RDoc::RDoc#parse_files
(ruby/rdoc#1274)

Commit ruby/rdoc@6cf6e1647b97, which went to v6.5.0, changed `RDoc::Options#parse`
to not call `#finish` in it. While the commit adjusted other call sites,
it missed `lib/rdoc/rubygems_hook.rb`.

`RDoc::Options#finish` prepares the include paths for `:include:`
directives. This has to be done before starting to parse sources.

I think this should fix ruby/net-http#193 +
ruby/net-http#194.

ruby/rdoc@d62da8ca09
  • Loading branch information
rhenium authored and matzbot committed Jan 8, 2025
1 parent 62a1528 commit e728170
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/rdoc/rubygems_hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ def generate
options = ::RDoc::Options.new
options.default_title = "#{@spec.full_name} Documentation"
options.parse args
options.quiet = !Gem.configuration.really_verbose
options.finish
end

options.quiet = !Gem.configuration.really_verbose

@rdoc = new_rdoc
@rdoc.options = options

Expand Down
13 changes: 12 additions & 1 deletion test/rdoc/test_rdoc_rubygems_hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,15 @@ def setup
@a.loaded_from = File.join(@tempdir, 'a-2', 'a-2.gemspec')

FileUtils.mkdir_p File.join(@tempdir, 'a-2', 'lib')
FileUtils.touch File.join(@tempdir, 'a-2', 'lib', 'a.rb')
FileUtils.touch File.join(@tempdir, 'a-2', 'README')
File.open(File.join(@tempdir, 'a-2', 'lib', 'a.rb'), 'w') do |f|
f.puts '# comment'
f.puts '# :include: include.txt'
f.puts 'class A; end'
end
File.open(File.join(@tempdir, 'a-2', 'include.txt'), 'w') do |f|
f.puts 'included content'
end

@hook = RDoc::RubyGemsHook.new @a

Expand Down Expand Up @@ -112,6 +119,10 @@ def test_generate
assert_equal %w[README lib], rdoc.options.files.sort

assert_equal 'MyTitle', rdoc.store.main

klass = rdoc.store.find_class_named('A')
refute_nil klass
assert_includes klass.comment.text, 'included content'
end

def test_generate_all
Expand Down

0 comments on commit e728170

Please sign in to comment.