Skip to content

Commit cf861cf

Browse files
committed
Fix loop termination when looking for the modifier comment of a class alias. Fixes issue #51
1 parent 5831af1 commit cf861cf

File tree

6 files changed

+29
-5
lines changed

6 files changed

+29
-5
lines changed

History.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* `ri []` and other special methods now work properly. Issue #52 by
77
ddebernardy.
88
* `ri` now has space between class comments from multiple files.
9-
* The stopdoc directive no longer creates Object references. Issue #55 by
10-
Simon Chiang
9+
* :stopdoc: no longer creates Object references. Issue #55 by Simon Chiang
10+
* :nodoc: works on class aliases now. Issue #51 by Steven G. Harms
1111

1212
=== 3.8 / 2011-06-29
1313

lib/rdoc/class_module.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,9 @@ def full_name
222222
end
223223
end
224224

225+
##
226+
# TODO: filter included items by #display?
227+
225228
def marshal_dump # :nodoc:
226229
attrs = attributes.sort.map do |attr|
227230
[ attr.name, attr.rw,

lib/rdoc/generator/template/darkfish/classpage.rhtml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@
176176
</div><!-- description -->
177177

178178
<% klass.each_section do |section, constants, attributes| %>
179+
<% constants = constants.select { |const| const.display? } %>
180+
<% attributes = attributes.select { |attr| attr.display? } %>
179181
<div id="<%= section.aref %>" class="documentation-section">
180182
<% if section.title then %>
181183
<h2 class="section-header">

lib/rdoc/markup/pre_process.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def handle_directive prefix, directive, param, code_object = nil,
118118
when 'nodoc' then
119119
return blankline unless code_object
120120
code_object.document_self = nil # notify nodoc
121-
code_object.document_children = param.to_s.downcase != 'all'
121+
code_object.document_children = param !~ /all/i
122122

123123
blankline
124124
when 'notnew', 'not_new', 'not-new' then

lib/rdoc/parser/ruby.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,8 @@ def parse_constant container, tk, comment
701701
when TkRPAREN, TkRBRACE, TkRBRACK, TkEND then
702702
nest -= 1
703703
when TkCOMMENT then
704-
if nest <= 0 && @scanner.lex_state == EXPR_END
704+
if nest <= 0 &&
705+
(@scanner.lex_state == EXPR_END || !@scanner.continue) then
705706
unget_tk tk
706707
break
707708
end
@@ -716,7 +717,6 @@ def parse_constant container, tk, comment
716717
end
717718

718719
container.add_module_alias mod, name, @top_level if mod
719-
get_tk # TkNL
720720
break
721721
end
722722
when TkNL then

test/test_rdoc_parser_ruby.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2193,6 +2193,25 @@ def method_name
21932193
assert @top_level.find_module_named('Example').ignored?
21942194
end
21952195

2196+
# This tests parse_comment
2197+
def test_parse_top_level_statements_constant_nodoc_integration
2198+
content = <<-CONTENT
2199+
class A
2200+
C = A # :nodoc:
2201+
end
2202+
CONTENT
2203+
2204+
util_parser content
2205+
2206+
@parser.parse_top_level_statements @top_level
2207+
2208+
klass = @top_level.find_module_named('A')
2209+
2210+
c = klass.constants.first
2211+
2212+
assert_nil c.document_self, 'C should not be documented'
2213+
end
2214+
21962215
def test_parse_yield_in_braces_with_parens
21972216
klass = RDoc::NormalClass.new 'Foo'
21982217
klass.parent = @top_level

0 commit comments

Comments
 (0)