@@ -40,9 +40,6 @@ def parser(*args) default_parser.new(*args) end
4040
4141 self . default_parser = DocstringParser
4242
43- # @return [Array<Tags::RefTag>] the list of reference tags
44- attr_reader :ref_tags
45-
4643 # @return [CodeObjects::Base] the object that owns the docstring.
4744 attr_accessor :object
4845
@@ -131,8 +128,7 @@ def to_s
131128 # @param [String] content the raw comments to be parsed
132129 def replace ( content , parse = true )
133130 content = content . join ( "\n " ) if content . is_a? ( Array )
134- @tags = [ ]
135- @ref_tags = [ ]
131+ @all_tags = [ ]
136132 if parse
137133 super ( parse_comments ( content ) )
138134 else
@@ -153,7 +149,7 @@ def replace(content, parse = true)
153149 def dup
154150 resolve_reference
155151 obj = super
156- %w( all summary tags ref_tags ) . each do |name |
152+ %w( all summary all_tags ) . each do |name |
157153 val = instance_variable_defined? ( "@#{ name } " ) && instance_variable_get ( "@#{ name } " )
158154 obj . instance_variable_set ( "@#{ name } " , val ? val . dup : nil )
159155 end
@@ -244,9 +240,9 @@ def add_tag(*tags)
244240 case tag
245241 when Tags ::Tag
246242 tag . object = object
247- @tags << tag
248- when Tags ::RefTag , Tags :: RefTagList
249- @ref_tags << tag
243+ @all_tags << tag
244+ when Tags ::RefTagList
245+ @all_tags << tag
250246 else
251247 raise ArgumentError , "expected Tag or RefTag, got #{ tag . class } (at index #{ i } )"
252248 end
@@ -271,11 +267,17 @@ def tag(name)
271267 # @param [#to_s] name the tag name to return data for, or nil for all tags
272268 # @return [Array<Tags::Tag>] the list of tags by the specified tag name
273269 def tags ( name = nil )
274- list = stable_sort_by ( @tags + convert_ref_tags , &:tag_name )
270+ list = @all_tags . map { |tag | convert_ref_tag ( tag ) } . flatten
271+ list = stable_sort_by ( list , &:tag_name )
275272 return list unless name
276273 list . select { |tag | tag . tag_name . to_s == name . to_s }
277274 end
278275
276+ # @return [Array<Tags::RefTag, Tags::RefTagList>] the list of reference tags
277+ def ref_tags
278+ @all_tags . select { |tag | tag . is_a? ( Tags ::RefTag ) || tag . is_a? ( Tags ::RefTagList ) }
279+ end
280+
279281 # Returns true if at least one tag by the name +name+ was declared
280282 #
281283 # @param [String] name the tag name to search for
@@ -298,8 +300,7 @@ def delete_tags(name)
298300 # @return [void]
299301 # @since 0.7.0
300302 def delete_tag_if ( &block )
301- @tags . delete_if ( &block )
302- @ref_tags . delete_if ( &block )
303+ @all_tags . delete_if ( &block )
303304 end
304305
305306 # Returns true if the docstring has no content that is visible to a template.
@@ -311,7 +312,7 @@ def blank?(only_visible_tags = true)
311312 if only_visible_tags
312313 empty? && !tags . any? { |tag | Tags ::Library . visible_tags . include? ( tag . tag_name . to_sym ) }
313314 else
314- empty? && @tags . empty? && @ref_tags . empty?
315+ empty? && @all_tags . empty?
315316 end
316317 end
317318
@@ -340,20 +341,26 @@ def resolve_reference
340341
341342 # Maps valid reference tags
342343 #
343- # @return [Array<Tags::RefTag>] the list of valid reference tags
344- def convert_ref_tags
345- list = @ref_tags . reject { |t | CodeObjects ::Proxy === t . owner }
346-
344+ # @param tag [Tags::Tag, Tags::RefTagList]
345+ # @return [Array<Tags::Tag>] dereferenced tags
346+ def convert_ref_tag ( tag )
347347 @ref_tag_recurse_count ||= 0
348348 @ref_tag_recurse_count += 1
349349 if @ref_tag_recurse_count > 2
350+ tag_and_name = [ "@#{ tag . tag_name } " , tag . name ] . compact . join ( " " )
350351 log . error "#{ @object . file } :#{ @object . line } : Detected circular reference tag in " \
351- "`#{ @object } ', ignoring all reference tags for this object " \
352- "(#{ @ref_tags . map { |t | "@#{ t . tag_name } " } . join ( ", " ) } )."
353- @ref_tags = [ ]
354- return @ref_tags
352+ "`#{ @object } '. Ignoring reference tag from #{ tag_and_name } to `#{ tag . owner } '."
353+ return [ ]
354+ end
355+ if tag . is_a? ( Tags ::RefTagList )
356+ if CodeObjects ::Proxy === tag . owner
357+ list = [ ]
358+ else
359+ list = tag . tags
360+ end
361+ else
362+ list = [ tag ]
355363 end
356- list = list . map ( &:tags ) . flatten
357364 @ref_tag_recurse_count -= 1
358365 list
359366 end
0 commit comments