Skip to content

Commit 729bd07

Browse files
committed
fix(options): RDoc::Options needs to call parse for its setup
This change workarounds the issue that `RDoc::Options.new` does not work itself without calling `parse` since some important setup logic lives in it. I believe we can improve this a lot by moving default option setup in `initialize`, for example, but it takes time. This usage of `RDoc::Options.new` is documented in README, and I believe this workaround solves it quickly and well enough.
1 parent 1e3ed08 commit 729bd07

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/rdoc/rdoc.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ def remove_unparseable files
442442

443443
def document options
444444
if RDoc::Options === options then
445-
@options = options
445+
@options = options.parse [] # Some logic only lives in `parse` method such as default generator
446446
else
447447
@options = RDoc::Options.load_options
448448
@options.parse options

test/rdoc/test_rdoc_rdoc.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ def setup
1414
@rdoc.instance_variable_set :@stats, @stats
1515
end
1616

17+
def test_document_with_bare_options
18+
rdoc = RDoc::RDoc.new
19+
options = RDoc::Options.new
20+
temp_dir do
21+
rdoc.document options
22+
end
23+
store = rdoc.store
24+
assert_equal nil, store.main
25+
assert_equal nil, store.title
26+
end
27+
1728
def test_document # functional test
1829
options = RDoc::Options.new
1930
options.files = [File.expand_path('../xref_data.rb', __FILE__)]

0 commit comments

Comments
 (0)