From 5e292172a1180aa594f50eda86fa4bc519ac1061 Mon Sep 17 00:00:00 2001 From: Rene Saarsoo Date: Thu, 21 Oct 2010 23:07:33 +0300 Subject: [PATCH] Added root_tag property to DocComment class. Therefore simplified the logic in set_default_name() method. --- doc_comment.rb | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/doc_comment.rb b/doc_comment.rb index bf8ac460..e65e84b1 100644 --- a/doc_comment.rb +++ b/doc_comment.rb @@ -4,6 +4,12 @@ module JsDuck class DocComment def initialize(tags) @tags = tags + + [:class, :function, :event, :cfg].each do |name| + if @tags[name] then + @root_tag = @tags[name] + end + end end # Sets the name property of the default at-tag. @@ -17,17 +23,13 @@ module JsDuck name = name_chain.last tagname = (name[0,1] == name[0,1].upcase) ? :class : :function - if !@tags[:class] && !@tags[:function] && !@tags[:event] && !@tags[:cfg] then - @tags[tagname] = {:name => (tagname == :function) ? name : name_chain.join(".")} - @tags[tagname][:doc] = @tags[:default][:doc] - elsif @tags[:class] && !@tags[:class][:name] then - @tags[:class][:name] = name - elsif @tags[:function] && !@tags[:function][:name] then - @tags[:function][:name] = name - elsif @tags[:event] && !@tags[:event][:name] then - @tags[:event][:name] = name - elsif @tags[:cfg] && !@tags[:cfg][:name] then - @tags[:cfg][:name] = name + if !@root_tag then + @root_tag = {:name => (tagname == :function) ? name : name_chain.join(".")} + @root_tag[:doc] = @tags[:default][:doc] + @tags[tagname] = @root_tag + @tags.delete(:default) + elsif !@root_tag[:name] then + @root_tag[:name] = name end end -- GitLab