Skip to content

Fix postfix :nodoc: #496

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

Merged
merged 2 commits into from
Aug 22, 2017
Merged
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
10 changes: 9 additions & 1 deletion lib/rdoc/parser/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,9 @@ def parse_class container, single, tk, comment

cls.line = line_no

# after end modifiers
read_documentation_modifiers cls, RDoc::CLASS_MODIFIERS

cls
end

Expand Down Expand Up @@ -1311,6 +1314,9 @@ def parse_method(container, single, tk, comment)

meth.comment = comment

# after end modifiers
read_documentation_modifiers meth, RDoc::METHOD_MODIFIERS

@stats.add_method meth
end

Expand Down Expand Up @@ -1542,6 +1548,9 @@ def parse_module container, single, tk, comment
mod.add_comment comment, @top_level
parse_statements mod

# after end modifiers
read_documentation_modifiers mod, RDoc::CLASS_MODIFIERS

@stats.add_module mod
end

Expand Down Expand Up @@ -1715,7 +1724,6 @@ def parse_statements(container, single = NORMAL, current_method = nil,
when TkEND then
nest -= 1
if nest == 0 then
read_documentation_modifiers container, RDoc::CLASS_MODIFIERS
container.ongoing_visibility = save_visibility

parse_comment container, tk, comment unless comment.empty?
Expand Down
25 changes: 25 additions & 0 deletions test/test_rdoc_parser_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2513,6 +2513,31 @@ def test_parse_require_dynamic_string
assert_equal 1, @top_level.requires.length
end

def test_parse_postfix_nodoc
util_parser <<-RUBY
class A
end # :nodoc:

class B
def a
end # :nodoc:

def b
end
end
RUBY

@parser.parse_statements @top_level

c_a = @top_level.classes.select(&:document_self).first
assert_equal 'B', c_a.full_name

assert_equal 2, @top_level.classes.length
assert_equal 1, @top_level.classes.count(&:document_self)
assert_equal 1, c_a.method_list.length
assert_equal 'B#b', c_a.method_list.first.full_name
end

def test_parse_statements_identifier_require
content = "require 'bar'"

Expand Down