Skip to content

Commit

Permalink
Merge pull request #1090 from p8/fix/nodoc-for-alias-method
Browse files Browse the repository at this point in the history
Don't document aliases with trailing `:nodoc` directive
  • Loading branch information
nobu committed Feb 9, 2024
2 parents 06137bd + 30f14e8 commit 265d572
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/rdoc/parser/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -789,8 +789,10 @@ def parse_alias(context, single, tk, comment)
al.line = line_no

read_documentation_modifiers al, RDoc::ATTR_MODIFIERS
context.add_alias al
@stats.add_alias al
if al.document_self or not @track_visibility
context.add_alias al
@stats.add_alias al
end

al
end
Expand Down
22 changes: 22 additions & 0 deletions test/rdoc/test_rdoc_parser_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3065,6 +3065,28 @@ def test_parse_statements_identifier_yields
assert_nil m.params, 'Module parameter not removed'
end

def test_parse_statements_nodoc_identifier_alias
klass = @top_level.add_class RDoc::NormalClass, 'Foo'

util_parser "\nalias :old :new # :nodoc:"

@parser.parse_statements klass, RDoc::Parser::Ruby::NORMAL, nil

assert_empty klass.aliases
assert_empty klass.unmatched_alias_lists
end

def test_parse_statements_nodoc_identifier_alias_method
klass = @top_level.add_class RDoc::NormalClass, 'Foo'

util_parser "\nalias_method :old :new # :nodoc:"

@parser.parse_statements klass, RDoc::Parser::Ruby::NORMAL, nil

assert_empty klass.aliases
assert_empty klass.unmatched_alias_lists
end

def test_parse_statements_stopdoc_alias
klass = @top_level.add_class RDoc::NormalClass, 'Foo'

Expand Down

0 comments on commit 265d572

Please sign in to comment.