-
Notifications
You must be signed in to change notification settings - Fork 447
Closed
Description
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.
jonathanhefner
Metadata
Metadata
Assignees
Labels
No labels