Skip to content

Consider comments within DSL #795

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions lib/rdoc/parser/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1867,11 +1867,11 @@ def parse_statements(container, single = NORMAL, current_method = nil,

when 'end' then
nest -= 1
if nest == 0 then
container.ongoing_visibility = save_visibility
container.ongoing_visibility = save_visibility

parse_comment container, tk, comment unless comment.empty?
parse_comment container, tk, comment unless comment.empty?

if nest == 0 then
return
end
end
Expand All @@ -1882,7 +1882,7 @@ def parse_statements(container, single = NORMAL, current_method = nil,
end

when :on_ident then
if nest == 1 and current_method.nil? then
if current_method.nil? then
keep_comment = parse_identifier container, single, tk, comment
end

Expand Down
25 changes: 25 additions & 0 deletions test/rdoc/test_rdoc_parser_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4297,4 +4297,29 @@ class D
assert_equal 'A::D', a_d.full_name
end

def test_parse_included
util_parser <<-CLASS
module A
module B
extend ActiveSupport::Concern
included do
##
# :singleton-method:
# Hello
mattr_accessor :foo
end
end
end
CLASS

@parser.scan

a = @store.find_module_named 'A'
assert_equal 'A', a.full_name
a_b = a.find_module_named 'B'
assert_equal 'A::B', a_b.full_name
meth = a_b.method_list.first
assert_equal 'foo', meth.name
assert_equal 'Hello', meth.comment.text
end
end