Skip to content

Commit 30f14e8

Browse files
committed
Don't document aliases with trailing :nodoc directive
Attribute readers and writers can be marked as `:nodoc` to keep them undocumented: ```ruby attr_reader :name # :nodoc: ``` For aliases this behaviour should be the same: ```ruby alias_method :old :new # :nodoc: ```
1 parent 06137bd commit 30f14e8

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)