Sha256: cfc35a01a0076b5f13a75f89f30ca6377f43e6829e41cd7cbcf82d35acc27606

Contents?: true

Size: 1.33 KB

Versions: 64

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true
def init
  tags = Tags::Library.visible_tags - [:abstract, :deprecated, :note, :todo]
  create_tag_methods(tags - [:example, :option, :overload, :see])
  sections :index, tags.map {|t| t.to_s.tr('.', '_').to_sym }
  sections.any(:overload).push(T('docstring'))
end

def return
  if object.type == :method
    return if object.constructor?
    return if object.tags(:return).size == 1 && object.tag(:return).types == ['void']
  end
  tag(:return)
end

def param
  tag(:param) if object.type == :method
end

private

def tag(name, opts = nil)
  return unless object.has_tag?(name)
  opts ||= options_for_tag(name)
  @no_names = opts[:no_names] ? true : false
  @no_types = opts[:no_types] ? true : false
  @name = name
  out = erb('tag')
  @no_names = nil
  @no_types = nil
  out
end

def create_tag_methods(tags)
  tags.each do |tag|
    tag_meth = tag.to_s.tr('.', '_')
    next if respond_to?(tag_meth)
    instance_eval(<<-eof, __FILE__, __LINE__ + 1)
      def #{tag_meth}; tag(#{tag.inspect}) end
    eof
  end
end

def options_for_tag(tag)
  opts = {:no_types => true, :no_names => true}
  case Tags::Library.factory_method_for(tag)
  when :with_types
    opts[:no_types] = false
  when :with_types_and_name
    opts[:no_types] = false
    opts[:no_names] = false
  when :with_name
    opts[:no_names] = false
  end
  opts
end

Version data entries

64 entries across 63 versions & 10 rubygems

Version Path
kinetic_sdk-5.0.29 gems/yard-0.9.36/templates/default/tags/setup.rb
kinetic_sdk-5.0.28 gems/yard-0.9.36/templates/default/tags/setup.rb
direct7-0.0.18 vendor/bundle/ruby/2.7.0/gems/yard-0.9.34/templates/default/tags/setup.rb
direct7-0.0.17 vendor/bundle/ruby/2.7.0/gems/yard-0.9.34/templates/default/tags/setup.rb
direct7-0.0.16 vendor/bundle/ruby/2.7.0/gems/yard-0.9.34/templates/default/tags/setup.rb
yard-0.9.37 templates/default/tags/setup.rb
kinetic_sdk-5.0.27 gems/yard-0.9.36/templates/default/tags/setup.rb
kinetic_sdk-5.0.26 gems/yard-0.9.36/templates/default/tags/setup.rb
kinetic_sdk-5.0.25 gems/yard-0.9.25/templates/default/tags/setup.rb
kinetic_sdk-5.0.24 gems/yard-0.9.25/templates/default/tags/setup.rb
direct7-0.0.13 vendor/bundle/ruby/2.7.0/gems/yard-0.9.34/templates/default/tags/setup.rb
yard-0.9.36 templates/default/tags/setup.rb
yard-0.9.35 templates/default/tags/setup.rb
direct7-0.0.12 vendor/bundle/ruby/2.7.0/gems/yard-0.9.34/templates/default/tags/setup.rb
kinetic_sdk-5.0.23 gems/yard-0.9.25/templates/default/tags/setup.rb
getargv-0.3.3-universal-darwin vendor/bundle/ruby/3.3.0/gems/yard-0.9.34/templates/default/tags/setup.rb
direct7-0.0.11 vendor/bundle/ruby/2.7.0/gems/yard-0.9.34/templates/default/tags/setup.rb
kinetic_sdk-5.0.22 gems/yard-0.9.25/templates/default/tags/setup.rb
kinetic_sdk-5.0.21 gems/yard-0.9.25/templates/default/tags/setup.rb
yard-0.9.34 templates/default/tags/setup.rb