Skip to content

Commit

Permalink
Support :nodoc: on method definition parameter end line
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng committed Feb 1, 2025
1 parent 0299ae1 commit 2973d9d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/rdoc/parser/prism_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def add_extends(names, line_no) # :nodoc:

# Adds a method defined by `def` syntax

def add_method(name, receiver_name:, receiver_fallback_type:, visibility:, singleton:, params:, calls_super:, block_params:, tokens:, start_line:, end_line:)
def add_method(name, receiver_name:, receiver_fallback_type:, visibility:, singleton:, params:, calls_super:, block_params:, tokens:, start_line:, args_end_line:, end_line:)
return if @in_proc_block

receiver = receiver_name ? find_or_create_module_path(receiver_name, receiver_fallback_type) : @container
Expand All @@ -524,6 +524,7 @@ def add_method(name, receiver_name:, receiver_fallback_type:, visibility:, singl
meth.comment = comment
end
handle_modifier_directive(meth, start_line)
handle_modifier_directive(meth, args_end_line)
handle_modifier_directive(meth, end_line)
return unless should_document?(meth)

Expand Down Expand Up @@ -854,6 +855,7 @@ def visit_singleton_class_node(node)

def visit_def_node(node)
start_line = node.location.start_line
args_end_line = node.parameters&.location&.end_line || start_line
end_line = node.location.end_line
@scanner.process_comments_until(start_line - 1)

Expand Down Expand Up @@ -904,6 +906,7 @@ def visit_def_node(node)
calls_super: calls_super,
tokens: tokens,
start_line: start_line,
args_end_line: args_end_line,
end_line: end_line
)
ensure
Expand Down
5 changes: 4 additions & 1 deletion test/rdoc/test_rdoc_parser_prism_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1391,9 +1391,12 @@ def nodoc2 # :nodoc:
def doc3; end
def nodoc3
end # :nodoc:
def nodoc4(arg1,
arg2) # :nodoc:
end
def doc4; end
# :stopdoc:
def nodoc4; end
def nodoc5; end
end
RUBY
klass = @store.find_class_named 'Foo'
Expand Down

0 comments on commit 2973d9d

Please # to comment.