Skip to content

Commit 265d572

Browse files
authored
Merge pull request #1090 from p8/fix/nodoc-for-alias-method
Don't document aliases with trailing `:nodoc` directive
2 parents 06137bd + 30f14e8 commit 265d572

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

lib/rdoc/parser/ruby.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,8 +789,10 @@ def parse_alias(context, single, tk, comment)
789789
al.line = line_no
790790

791791
read_documentation_modifiers al, RDoc::ATTR_MODIFIERS
792-
context.add_alias al
793-
@stats.add_alias al
792+
if al.document_self or not @track_visibility
793+
context.add_alias al
794+
@stats.add_alias al
795+
end
794796

795797
al
796798
end

test/rdoc/test_rdoc_parser_ruby.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3065,6 +3065,28 @@ def test_parse_statements_identifier_yields
30653065
assert_nil m.params, 'Module parameter not removed'
30663066
end
30673067

3068+
def test_parse_statements_nodoc_identifier_alias
3069+
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
3070+
3071+
util_parser "\nalias :old :new # :nodoc:"
3072+
3073+
@parser.parse_statements klass, RDoc::Parser::Ruby::NORMAL, nil
3074+
3075+
assert_empty klass.aliases
3076+
assert_empty klass.unmatched_alias_lists
3077+
end
3078+
3079+
def test_parse_statements_nodoc_identifier_alias_method
3080+
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
3081+
3082+
util_parser "\nalias_method :old :new # :nodoc:"
3083+
3084+
@parser.parse_statements klass, RDoc::Parser::Ruby::NORMAL, nil
3085+
3086+
assert_empty klass.aliases
3087+
assert_empty klass.unmatched_alias_lists
3088+
end
3089+
30683090
def test_parse_statements_stopdoc_alias
30693091
klass = @top_level.add_class RDoc::NormalClass, 'Foo'
30703092

0 commit comments

Comments
 (0)