Skip to content
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

Partial .rdoc_options is not supported #405

Closed
halostatue opened this issue May 3, 2016 · 1 comment
Closed

Partial .rdoc_options is not supported #405

halostatue opened this issue May 3, 2016 · 1 comment

Comments

@halostatue
Copy link

halostatue commented May 3, 2016

I would like to be able to have a partial .rdoc_options file:

--- !ruby/object:RDoc::Options
  exclude: !ruby/regexp /(?-mix:lib\/generators\/.*\/templates\/.*\.rb)/

This, however, causes a failure that cannot be debugged:

uh-oh! RDoc had a problem:
undefined method `reject' for nil:NilClass

run with --debug for full backtrace

It can’t be debugged because loading .rdoc_options happens before command-line parsing. However, the problem is in Options#sanitize_path (lib/rdoc/options.rb:1154 of rdoc 4.2.2) as the path to be sanitized is nil, as called from Options#init_with(lib/rdoc/options.rb:416 of rdoc 4.2.2). I found this with the output from ruby -d -S rdoc.

The fix for this is relatively simple, but verbose:

diff --git a/lib/rdoc/options.rb b/lib/rdoc/options.rb
index 17b0bb1..ed625d5 100644
--- a/lib/rdoc/options.rb
+++ b/lib/rdoc/options.rb
@@ -392,30 +392,32 @@ class RDoc::Options
   def init_with map # :nodoc:
     init_ivars

-    encoding = map['encoding']
-    @encoding = if Object.const_defined? :Encoding then
-                  encoding ? Encoding.find(encoding) : encoding
-                end
+    if map['encoding']
+      encoding = map['encoding']
+      @encoding = if Object.const_defined? :Encoding then
+                    encoding ? Encoding.find(encoding) : encoding
+                  end
+    end

-    @charset        = map['charset']
-    @exclude        = map['exclude']
-    @generator_name = map['generator_name']
-    @hyperlink_all  = map['hyperlink_all']
-    @line_numbers   = map['line_numbers']
-    @locale_name    = map['locale_name']
-    @locale_dir     = map['locale_dir']
-    @main_page      = map['main_page']
-    @markup         = map['markup']
-    @op_dir         = map['op_dir']
-    @show_hash      = map['show_hash']
-    @tab_width      = map['tab_width']
-    @template_dir   = map['template_dir']
-    @title          = map['title']
-    @visibility     = map['visibility']
-    @webcvs         = map['webcvs']
-
-    @rdoc_include = sanitize_path map['rdoc_include']
-    @static_path  = sanitize_path map['static_path']
+    @charset        = map['charset'] if map['charset']
+    @exclude        = map['exclude'] if map['exclude']
+    @generator_name = map['generator_name'] if map['generator_name']
+    @hyperlink_all  = map['hyperlink_all'] if map['hyperlink_all']
+    @line_numbers   = map['line_numbers'] if map['line_numbers']
+    @locale_name    = map['locale_name'] if map['locale_name']
+    @locale_dir     = map['locale_dir'] if map['locale_dir']
+    @main_page      = map['main_page'] if map['main_page']
+    @markup         = map['markup'] if map['markup']
+    @op_dir         = map['op_dir'] if map['op_dir']
+    @show_hash      = map['show_hash'] if map['show_hash']
+    @tab_width      = map['tab_width'] if map['tab_width']
+    @template_dir   = map['template_dir'] if map['template_dir']
+    @title          = map['title'] if map['title']
+    @visibility     = map['visibility'] if map['visibility']
+    @webcvs         = map['webcvs'] if map['webcvs']
+
+    @rdoc_include = sanitize_path map['rdoc_include'] if map['rdoc_include']
+    @static_path  = sanitize_path map['static_path'] if map['static_path']
   end

   def yaml_initialize tag, map # :nodoc:

I have a branch that has the main fix, but no test changes to support this. I can turn this into a pull request if there is interest.

@aycabta
Copy link
Member

aycabta commented Sep 1, 2021

This is fixed by #796, and it has been released as v6.3.1. Please check it by gem install rdoc.

@aycabta aycabta closed this as completed Sep 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants