You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the method_source gem to retrieve comments associated with instance methods, it appears that the comments from preceding methods are also included. This results in incorrect comment retrieval, especially when there are multiple methods with comments in between. I made a little script to show it:
require'method_source'classStringTransformerdefinitialize(str)@str=strend# Reverse the stringdefreverse_string@str.reverseend# Convert the string to uppercase# TODO: Implement this method# def uppercase_string# end# Replace spaces with underscoresdefreplace_spaces@str.gsub(' ','_')endendStringTransformer.instance_method(:reverse_string).comment.display# => # Reverse the stringStringTransformer.instance_method(:replace_spaces).comment.display# => # Convert the string to uppercase# # TODO Implement this method# # def uppercase_string# # end# # Replace spaces with underscores
I format It with a default Rubocop configuration.
I think the expected behavior should be:
StringTransformer.instance_method(:reverse_string).comment.display# => # Reverse the stringStringTransformer.instance_method(:replace_spaces).comment.display# => # Replace spaces with underscores
I looked into the major documentation tools in Ruby (YARD and RDoc) and none support parsing block comments separated by a whitespace (though I am not 100% sure). However, I think the comment before the method should be extracted until the next whitespace and not more.
The text was updated successfully, but these errors were encountered:
When using the method_source gem to retrieve comments associated with instance methods, it appears that the comments from preceding methods are also included. This results in incorrect comment retrieval, especially when there are multiple methods with comments in between. I made a little script to show it:
I format It with a default Rubocop configuration.
I think the expected behavior should be:
I looked into the major documentation tools in Ruby (YARD and RDoc) and none support parsing block comments separated by a whitespace (though I am not 100% sure). However, I think the comment before the method should be extracted until the next whitespace and not more.
The text was updated successfully, but these errors were encountered: