Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions lib/rdoc/parser/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,6 @@ def handle_meta_method_comment(comment, directives, node)
@container,
comment: comment,
directives: directives,
dont_rename_initialize: false,
line_no: line_no,
visibility: visibility,
singleton: @singleton || singleton_method,
Expand Down Expand Up @@ -722,7 +721,7 @@ def add_method(method_name, receiver_name:, receiver_fallback_type:, visibility:
)
end

private def internal_add_method(method_name, container, comment:, dont_rename_initialize: false, directives:, modifier_comment_lines: nil, line_no:, visibility:, singleton:, params:, calls_super:, block_params:, tokens:, type_signature_lines: nil) # :nodoc:
private def internal_add_method(method_name, container, comment:, directives:, modifier_comment_lines: nil, line_no:, visibility:, singleton:, params:, calls_super:, block_params:, tokens:, type_signature_lines: nil) # :nodoc:
meth = RDoc::AnyMethod.new(method_name, singleton: singleton)
meth.comment = comment
handle_code_object_directives(meth, directives) if directives
Expand All @@ -746,16 +745,10 @@ def add_method(method_name, receiver_name:, receiver_fallback_type:, visibility:
meth.calls_super = calls_super
meth.block_params ||= block_params if block_params
meth.type_signature_lines = type_signature_lines
container.add_method(meth)
record_location(meth)
meth.start_collecting_tokens(:ruby)
tokens.each do |token|
meth.token_stream << token
end

# Rename after add_method to register duplicated 'new' and 'initialize'
# defined in c and ruby.
if !dont_rename_initialize && method_name == 'initialize' && !singleton
# An instance method `initialize` is documented as `::new` unless the
# :notnew: directive is given
if method_name == 'initialize' && !singleton
if meth.dont_rename_initialize
meth.visibility = :protected
else
Expand All @@ -764,6 +757,13 @@ def add_method(method_name, receiver_name:, receiver_fallback_type:, visibility:
meth.visibility = :public
end
end

record_location(meth)
container.add_method(meth)
meth.start_collecting_tokens(:ruby)
tokens.each do |token|
meth.token_stream << token
end
end

# Find or create module or class from a given module name using Ruby lexical
Expand Down