Skip to content

Commit 31658f2

Browse files
authored
Merge pull request #496 from aycabta/fix-postfix-nodoc
Fix postfix :nodoc:
2 parents 6a81c8a + 06edc79 commit 31658f2

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

lib/rdoc/parser/ruby.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,9 @@ def parse_class container, single, tk, comment
752752

753753
cls.line = line_no
754754

755+
# after end modifiers
756+
read_documentation_modifiers cls, RDoc::CLASS_MODIFIERS
757+
755758
cls
756759
end
757760

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

13121315
meth.comment = comment
13131316

1317+
# after end modifiers
1318+
read_documentation_modifiers meth, RDoc::METHOD_MODIFIERS
1319+
13141320
@stats.add_method meth
13151321
end
13161322

@@ -1542,6 +1548,9 @@ def parse_module container, single, tk, comment
15421548
mod.add_comment comment, @top_level
15431549
parse_statements mod
15441550

1551+
# after end modifiers
1552+
read_documentation_modifiers mod, RDoc::CLASS_MODIFIERS
1553+
15451554
@stats.add_module mod
15461555
end
15471556

@@ -1715,7 +1724,6 @@ def parse_statements(container, single = NORMAL, current_method = nil,
17151724
when TkEND then
17161725
nest -= 1
17171726
if nest == 0 then
1718-
read_documentation_modifiers container, RDoc::CLASS_MODIFIERS
17191727
container.ongoing_visibility = save_visibility
17201728

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

test/test_rdoc_parser_ruby.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2542,6 +2542,31 @@ def test_parse_require_dynamic_string
25422542
assert_equal 1, @top_level.requires.length
25432543
end
25442544

2545+
def test_parse_postfix_nodoc
2546+
util_parser <<-RUBY
2547+
class A
2548+
end # :nodoc:
2549+
2550+
class B
2551+
def a
2552+
end # :nodoc:
2553+
2554+
def b
2555+
end
2556+
end
2557+
RUBY
2558+
2559+
@parser.parse_statements @top_level
2560+
2561+
c_a = @top_level.classes.select(&:document_self).first
2562+
assert_equal 'B', c_a.full_name
2563+
2564+
assert_equal 2, @top_level.classes.length
2565+
assert_equal 1, @top_level.classes.count(&:document_self)
2566+
assert_equal 1, c_a.method_list.length
2567+
assert_equal 'B#b', c_a.method_list.first.full_name
2568+
end
2569+
25452570
def test_parse_statements_identifier_require
25462571
content = "require 'bar'"
25472572

0 commit comments

Comments
 (0)