From 729bd0760911aa9294d274bc0f5ff4cbd3c33831 Mon Sep 17 00:00:00 2001 From: OKURA Masafumi Date: Mon, 24 Mar 2025 05:08:16 +0900 Subject: [PATCH] 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. --- lib/rdoc/rdoc.rb | 2 +- test/rdoc/test_rdoc_rdoc.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb index 8351bf8ffe..c2b9afa7a7 100644 --- a/lib/rdoc/rdoc.rb +++ b/lib/rdoc/rdoc.rb @@ -442,7 +442,7 @@ def remove_unparseable files def document options if RDoc::Options === options then - @options = options + @options = options.parse [] # Some logic only lives in `parse` method such as default generator else @options = RDoc::Options.load_options @options.parse options diff --git a/test/rdoc/test_rdoc_rdoc.rb b/test/rdoc/test_rdoc_rdoc.rb index 050f92274f..f15b2b2125 100644 --- a/test/rdoc/test_rdoc_rdoc.rb +++ b/test/rdoc/test_rdoc_rdoc.rb @@ -14,6 +14,17 @@ def setup @rdoc.instance_variable_set :@stats, @stats end + def test_document_with_bare_options + rdoc = RDoc::RDoc.new + options = RDoc::Options.new + temp_dir do + rdoc.document options + end + store = rdoc.store + assert_equal nil, store.main + assert_equal nil, store.title + end + def test_document # functional test options = RDoc::Options.new options.files = [File.expand_path('../xref_data.rb', __FILE__)]