Skip to content

Finalize RDoc::Options before calling RDoc::RDoc#parse_files #1274

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 1 commit into from
Jan 8, 2025

Conversation

rhenium
Copy link
Member

@rhenium rhenium commented Jan 8, 2025

Commit 6cf6e16, 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.

Commit 6cf6e16, 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.
Copy link
Member

@st0012 st0012 left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

@st0012 st0012 merged commit d62da8c into ruby:master Jan 8, 2025
24 checks passed
matzbot pushed a commit to ruby/ruby that referenced this pull request Jan 8, 2025
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
tompng added a commit that referenced this pull request Apr 23, 2025
…1347)

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
```ruby
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'gem install net-http' generates warnings
2 participants