Sha256: 97617ee9527a1c226e365aa67838f268f2cef8849067f9f02da219746bccc9d2

Contents?: true

Size: 1.29 KB

Versions: 65

Compression:

Stored size: 1.29 KB

Contents

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.gsub('.', '_').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 = true if opts[:no_names]
  @no_types = true if opts[:no_types]
  @name = name
  out = erb('tag')
  @no_names, @no_types = nil, nil
  out
end

def create_tag_methods(tags)
  tags.each do |tag|
    tag_meth = tag.to_s.gsub('.', '_')
    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

65 entries across 58 versions & 10 rubygems

Version Path
enumerable-statistics-2.0.7 yard/templates/mathjax/tags/setup.rb
enumerable-statistics-2.0.6 yard/templates/mathjax/tags/setup.rb
enumerable-statistics-2.0.5 yard/templates/mathjax/tags/setup.rb
enumerable-statistics-2.0.3 yard/templates/mathjax/tags/setup.rb
enumerable-statistics-2.0.2 yard/templates/mathjax/tags/setup.rb
enumerable-statistics-2.0.1 yard/templates/mathjax/tags/setup.rb
enumerable-statistics-2.0.0 yard/templates/mathjax/tags/setup.rb
enumerable-statistics-2.0.0.pre yard/templates/mathjax/tags/setup.rb
abaci-0.3.0 vendor/bundle/gems/yard-0.9.1/templates/default/tags/setup.rb
abaci-0.3.0 vendor/bundle/gems/yard-0.9.2/templates/default/tags/setup.rb
enumerable-statistics-1.0.1 yard/templates/mathjax/tags/setup.rb
my_yard-0.0.3 home_my_yard/templates/visualruby/tags/setup.rb
my_yard-0.0.2 home_my_yard/templates/visualruby/tags/setup.rb
yard-0.9.5 templates/default/tags/setup.rb
yard-0.9.4 templates/default/tags/setup.rb
yard-0.9.3 templates/default/tags/setup.rb
yard-0.9.2 templates/default/tags/setup.rb
yard-0.9.1 templates/default/tags/setup.rb
my_yard-0.0.1 home_my_yard/templates/visualruby/tags/setup.rb
yard-0.9.0 templates/default/tags/setup.rb