Sha256: 66d8a94f2bc822192c985d887f7354f2a8562a1160487fc94d990ae966ec1a85

Contents?: true

Size: 1.33 KB

Versions: 6

Compression:

Stored size: 1.33 KB

Contents

module YARD
  module Tags
    class Tag
      attr_reader :tag_name, :text, :types, :name
      attr_accessor :object

      ##
      # Creates a new tag object with a tag name and text. Optionally, formally declared types
      # and a key name can be specified.
      #
      # Types are mainly for meta tags that rely on type information, such as +param+, +return+, etc.
      # 
      # Key names are for tags that declare meta data for a specific key or name, such as +param+,
      # +raise+, etc.
      #
      # @param tag_name                the tag name to create the tag for
      # @param [String] text           the descriptive text for this tag
      # @param [Array<String>] types   optional type list of formally declared types
      #                                for the tag
      # @param [String] name           optional key name which the tag refers to
      def initialize(tag_name, text, types = nil, name = nil)
        @tag_name, @text, @name, @types = tag_name.to_s, text, name, (types ? [types].flatten.compact : nil)
      end

      ##
      # Convenience method to access the first type specified. This should mainly
      # be used for tags that only specify one type.
      #
      # @return [String] the first of the list of specified types 
      # @see #types
      def type
        types.first
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
yard-0.4.0 lib/yard/tags/tag.rb
yard-0.2.3.5 lib/yard/tags/tag.rb
yard-0.2.3.4 lib/yard/tags/tag.rb
yard-0.2.3.2 lib/yard/tags/tag.rb
yard-0.2.3.3 lib/yard/tags/tag.rb
yard-0.2.3 lib/yard/tags/tag.rb