@@ -478,7 +478,7 @@ def parse_attr(context, single, tk, comment)
478478
479479 read_documentation_modifiers att , RDoc ::ATTR_MODIFIERS
480480
481- context . add_attribute att if att . document_self
481+ context . add_attribute att
482482
483483 @stats . add_attribute att
484484 else
@@ -499,6 +499,8 @@ def parse_attr_accessor(context, single, tk, comment)
499499
500500 tmp = RDoc ::CodeObject . new
501501 read_documentation_modifiers tmp , RDoc ::ATTR_MODIFIERS
502+ # TODO In most other places we let the context keep track of document_self
503+ # and add found items appropriately but here we do not. I'm not sure why.
502504 return unless tmp . document_self
503505
504506 case tk . name
@@ -557,7 +559,7 @@ def parse_alias(context, single, tk, comment)
557559 al . line = line_no
558560
559561 read_documentation_modifiers al , RDoc ::ATTR_MODIFIERS
560- context . add_alias al if al . document_self
562+ context . add_alias al
561563 @stats . add_alias al
562564
563565 al
@@ -633,7 +635,7 @@ def parse_class(container, single, tk, comment)
633635 cls . offset = offset
634636 cls . line = line_no
635637
636- cls . add_comment comment , @top_level if cls . document_self
638+ cls . add_comment comment , @top_level
637639
638640 @top_level . add_to_classes_or_modules cls
639641 @stats . add_class cls
@@ -657,7 +659,7 @@ def parse_class(container, single, tk, comment)
657659
658660 # notify :nodoc: all if not a constant-named class/module
659661 # (and remove any comment)
660- unless name =~ /\A (::)?[A-Z]/
662+ unless name =~ /\A (::)?[A-Z]/ then
661663 other . document_self = nil
662664 other . document_children = false
663665 other . clear_comment
@@ -758,7 +760,7 @@ def parse_constant(container, tk, comment)
758760 read_documentation_modifiers con , RDoc ::CONSTANT_MODIFIERS
759761
760762 @stats . add_constant con
761- container . add_constant con if con . document_self
763+ container . add_constant con
762764 true
763765 end
764766
@@ -797,7 +799,7 @@ def parse_comment(container, tk, comment)
797799
798800 return unless meth . name
799801
800- container . add_method meth if meth . document_self
802+ container . add_method meth
801803
802804 meth . comment = comment
803805
@@ -818,7 +820,6 @@ def parse_comment(container, tk, comment)
818820 att . line = line_no
819821
820822 container . add_attribute att
821-
822823 @stats . add_attribute att
823824 end
824825
@@ -882,7 +883,6 @@ def parse_meta_attr(context, single, tk, comment)
882883
883884 tmp = RDoc ::CodeObject . new
884885 read_documentation_modifiers tmp , RDoc ::ATTR_MODIFIERS
885- return unless tmp . document_self
886886
887887 if comment . sub! ( /^# +:?(attr(_reader|_writer|_accessor)?): *(\S *).*?\n /i , '' ) then
888888 rw = case $1
@@ -969,7 +969,7 @@ def parse_meta_method(container, single, tk, comment)
969969
970970 extract_call_seq comment , meth
971971
972- container . add_method meth if meth . document_self
972+ container . add_method meth
973973
974974 last_tk = tk
975975
@@ -1238,7 +1238,7 @@ def parse_module(container, single, tk, comment)
12381238 mod . record_location @top_level
12391239
12401240 read_documentation_modifiers mod , RDoc ::CLASS_MODIFIERS
1241- mod . add_comment comment , @top_level if mod . document_self
1241+ mod . add_comment comment , @top_level
12421242 parse_statements ( mod )
12431243
12441244 @top_level . add_to_classes_or_modules mod
@@ -1341,23 +1341,15 @@ def parse_statements(container, single = NORMAL, current_method = nil,
13411341 end
13421342
13431343 when TkDEF then
1344- if container . document_self then
1345- parse_method container , single , tk , comment
1346- else
1347- nest += 1
1348- end
1344+ parse_method container , single , tk , comment
13491345
13501346 when TkCONSTANT then
1351- if container . document_self then
1352- if not parse_constant container , tk , comment then
1353- try_parse_comment = true
1354- end
1347+ unless parse_constant container , tk , comment then
1348+ try_parse_comment = true
13551349 end
13561350
13571351 when TkALIAS then
1358- if container . document_self and not current_method then
1359- parse_alias container , single , tk , comment
1360- end
1352+ parse_alias container , single , tk , comment unless current_method
13611353
13621354 when TkYIELD then
13631355 if current_method . nil? then
@@ -1395,12 +1387,11 @@ def parse_statements(container, single = NORMAL, current_method = nil,
13951387 when /^attr_(reader|writer|accessor)$/ then
13961388 parse_attr_accessor container , single , tk , comment
13971389 when 'alias_method' then
1398- parse_alias container , single , tk , comment if
1399- container . document_self
1390+ parse_alias container , single , tk , comment
14001391 when 'require' , 'include' then
14011392 # ignore
14021393 else
1403- if container . document_self and comment =~ /\A #\# $/ then
1394+ if comment =~ /\A #\# $/ then
14041395 case comment
14051396 when /^# +:?attr(_reader|_writer|_accessor)?:/ then
14061397 parse_meta_attr container , single , tk , comment
@@ -1523,11 +1514,12 @@ def parse_symbol_in_arg
15231514 end
15241515
15251516 ##
1526- # Parses statements at the toplevel in +container+
1517+ # Parses statements in the top-level +container+
15271518
15281519 def parse_top_level_statements ( container )
15291520 comment = collect_first_comment
15301521 look_for_directives_in ( container , comment )
1522+ # HACK move if to RDoc::Context#comment=
15311523 container . comment = comment if container . document_self unless comment . empty?
15321524 parse_statements container , NORMAL , nil , comment
15331525 end
0 commit comments