Skip to content

Commit c5a64f4

Browse files
committed
Fix rubygems hook execution when gemspec.rdoc_options contains --ri
`finish` should be called before `rdoc.parse_files(options.files)`. `finish` should be called after `options.setup_generator`. We need to use a different RDoc::Options object for parse_files phase and document generation phase.
1 parent 2824bb6 commit c5a64f4

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

lib/rdoc/rubygems_hook.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,18 +182,18 @@ def generate
182182
options.default_title = "#{@spec.full_name} Documentation"
183183
options.parse args
184184
options.quiet = !Gem.configuration.really_verbose
185-
options.finish
186185
end
187186

188187
@rdoc = new_rdoc
189-
@rdoc.options = options
190-
191-
@rdoc.store = RDoc::Store.new(options)
192188

193189
say "Parsing documentation for #{@spec.full_name}"
194190

195191
Dir.chdir @spec.full_gem_path do
196-
@rdoc.parse_files options.files
192+
parse_options = options.dup
193+
parse_options.finish
194+
@rdoc.options = parse_options
195+
@rdoc.store = RDoc::Store.new(parse_options)
196+
@rdoc.parse_files parse_options.files
197197
end
198198

199199
document 'ri', options, @ri_dir if

test/rdoc/test_rdoc_rubygems_hook.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,18 @@ def test_generate_no_overwrite
241241
assert_path_not_exist File.join(@a.doc_dir('ri'), 'cache.ri')
242242
end
243243

244+
def test_generate_with_ri_opt
245+
@a.rdoc_options << '--ri'
246+
FileUtils.mkdir_p @a.doc_dir
247+
FileUtils.mkdir_p File.join(@a.gem_dir, 'lib')
248+
@hook.generate_rdoc = true
249+
@hook.generate_ri = true
250+
@hook.generate
251+
252+
assert_path_exist File.join(@a.doc_dir('rdoc'), 'index.html')
253+
assert_path_exist File.join(@a.doc_dir('ri'), 'cache.ri')
254+
end
255+
244256
def test_new_rdoc
245257
assert_kind_of RDoc::RDoc, @hook.new_rdoc
246258
end

0 commit comments

Comments
 (0)