Skip to content

Commit e26fdfc

Browse files
committed
Get constant body without last comment
1 parent d881b6b commit e26fdfc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/rdoc/parser/ruby.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,7 @@ def parse_constant_body container, constant, is_array_or_hash # :nodoc:
935935

936936
tk = get_tk
937937

938+
body = nil
938939
loop do
939940
break if tk.nil?
940941
if :on_semicolon == tk[:kind] then
@@ -952,9 +953,12 @@ def parse_constant_body container, constant, is_array_or_hash # :nodoc:
952953
nest -= 1
953954
elsif (:on_comment == tk[:kind] or :on_embdoc == tk[:kind]) then
954955
unget_tk tk
955-
read_documentation_modifiers constant, RDoc::CONSTANT_MODIFIERS
956956
if nest <= 0 and RDoc::RipperStateLex.end?(tk) then
957+
body = get_tkread_clean(/^[ \t]+/, '')
958+
read_documentation_modifiers constant, RDoc::CONSTANT_MODIFIERS
957959
break
960+
else
961+
read_documentation_modifiers constant, RDoc::CONSTANT_MODIFIERS
958962
end
959963
elsif :on_const == tk[:kind] then
960964
rhs_name << tk[:text]
@@ -975,7 +979,7 @@ def parse_constant_body container, constant, is_array_or_hash # :nodoc:
975979
tk = get_tk
976980
end
977981

978-
get_tkread_clean(/^[ \t]+/, '')
982+
body ? body : get_tkread_clean(/^[ \t]+/, '')
979983
end
980984

981985
##

0 commit comments

Comments
 (0)