Skip to content

Fix rubygems hook execution when gemspec.rdoc_options contains --ri #1347

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 23, 2025

Conversation

tompng
Copy link
Member

@tompng tompng commented Apr 23, 2025

Probably fixes #1343

options.finish is called twice while generating document through rubygems_hook.
If gemspec has spec.rdoc_options << '--ri', document generation fails.
Looks like this double-finish is introduced in #1274

Detail of the bug

options = ::RDoc::Options.new
options.parse args # if --ri is specified, generator is set to 'ri'
options.finish # @template='ri' and @template_dir=nil is configured here
@rdoc.parse_files options.files

document 'ri', options, @rdoc_dir
document 'darkfish', options, @rdoc_dir # Calls options.setup_generator('darkfish') and options.finish but @template_dir is already configured for 'ri'

Fix

Constraints are:

  • Need to call finish only once for each RDoc::Options instance
  • finish should be called before rdoc.parse_files(options.files)
  • finish should be called after options.setup_generator
  • It is better to call rdoc.parse_files only once

We need to use a different RDoc::Options object for parse_files phase and document generation phase.

`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.
Copy link
Member

@kou kou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1


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

Dir.chdir @spec.full_gem_path do
@rdoc.parse_files options.files
parse_options = options.dup
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about adding a comment why we need to create a separated options here?

@tompng tompng merged commit 406ae7e into ruby:master Apr 23, 2025
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generating RDoc for RDoc fails in Ruby 3.4.x and following
2 participants