Skip to content

Commit

Permalink
Don't document aliases with trailing :nodoc directive
Browse files Browse the repository at this point in the history
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:
```
  • Loading branch information
p8 committed Feb 8, 2024
1 parent 06137bd commit 30f14e8
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 30f14e8

Please sign in to comment.