Skip to content

docs(README): fix the example that doesn't work #1325

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

Closed
wants to merge 1 commit into from

Conversation

okuramasafumi
Copy link
Contributor

RDoc::RDoc.new.document(RDoc::Options.new)

fails with the following error:

/Users/okuramasafumi/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/rdoc-6.12.0/lib/rdoc/options.rb:522:in 'RDoc::Options#check_files': undefined method 'delete_if' for nil (NoMethodError)

I think this should be fixed, but for now modifying an example might be enough.

```ruby
RDoc::RDoc.new.document(RDoc::Options.new)
```

fails with the following error:

```
/Users/okuramasafumi/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/rdoc-6.12.0/lib/rdoc/options.rb:522:in 'RDoc::Options#check_files': undefined method 'delete_if' for nil (NoMethodError)
```

I think this should be fixed, but for now modifying an example might be
enough.
@st0012
Copy link
Member

st0012 commented Mar 23, 2025

If you think this should be fixed, which I agree, can you make a PR to address the root problem instead? It should be a rather straightforward one

@tompng
Copy link
Member

tompng commented Mar 23, 2025

The failure is because some required setups for RDoc::Options are missing.
Since required things are missing, failing is not a problem. Of course the error message is not user friendly, though.

I think rdoc.document(command_line_args) is for command line execution and rdoc.document(options) is for generating document programmatically.
So README should use rdoc.document(options) with adding minimal option setups that succeeds without error.

@okuramasafumi
Copy link
Contributor Author

@st0012 @tompng Thank you for the quick response, I fixed the root issue in #1328
That is still a workaround and not an ideal solution, but modifying/refactoring RDoc::Options class feels too much for this one problem.

rdoc = RDoc::RDoc.new
rdoc.document options
rdoc.document([]) # This generates documentation for all files in the current directory
Copy link
Member

@tompng tompng Mar 24, 2025

Choose a reason for hiding this comment

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

How about this?

options = RDoc::Options.new
options.files = ['./a.rb', './b.rb']
options.setup_generator 'darkfish'
# see RDoc::Options for more setups

rdoc = RDoc::RDoc.new
rdoc.document options

Some example of options setups are in TestRDocRDoc#test_document

tompng added a commit that referenced this pull request Apr 3, 2025
Add minimal option setup(options.files and options.generator) to make
the example code work.

#1325 (comment)
@tompng
Copy link
Member

tompng commented Apr 3, 2025

README fixed in #1337

@tompng tompng closed this Apr 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants