Sha256: 9630439ef9ebad981330ef5d0e503a9fcbed905a707304143c93bd59f9dd5f9a

Contents?: true

Size: 1.25 KB

Versions: 17

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true
def init
  return if object.docstring.blank? && !object.has_tag?(:api)
  sections :index, [:private, :deprecated, :abstract, :todo, :note, :returns_void, :text], T('tags')
end

def private
  return unless object.has_tag?(:api) && object.tag(:api).text == 'private'
  erb(:private)
end

def abstract
  return unless object.has_tag?(:abstract)
  erb(:abstract)
end

def deprecated
  return unless object.has_tag?(:deprecated)
  erb(:deprecated)
end

def todo
  return unless object.has_tag?(:todo)
  erb(:todo)
end

def note
  return unless object.has_tag?(:note)
  erb(:note)
end

def returns_void
  return unless object.type == :method
  return if object.name == :initialize && object.scope == :instance
  return unless object.tags(:return).size == 1 && object.tag(:return).types == ['void']
  erb(:returns_void)
end

def docstring_text
  text = ""
  unless object.tags(:overload).size == 1 && object.docstring.empty?
    text = object.docstring
  end

  if text.strip.empty? && object.tags(:return).size == 1 && object.tag(:return).text
    text = object.tag(:return).text.gsub(/\A([a-z])/, &:downcase)
    text = "Returns #{text}" unless text.empty? || text =~ /^\s*return/i
    text = text.gsub(/\A([a-z])/, &:upcase)
  end

  text.strip
end

Version data entries

17 entries across 16 versions & 4 rubygems

Version Path
yard-0.9.20 templates/default/docstring/setup.rb
yard-0.9.19 templates/default/docstring/setup.rb
yard-0.9.16 templates/default/docstring/setup.rb
yard-0.9.15 templates/default/docstring/setup.rb
yard-0.9.14 templates/default/docstring/setup.rb
yard-0.9.13 templates/default/docstring/setup.rb
yard-0.9.12 templates/default/docstring/setup.rb
yard-0.9.11 templates/default/docstring/setup.rb
yard-0.9.10 templates/default/docstring/setup.rb
yard-0.9.9 templates/default/docstring/setup.rb
etude_for_ruby-0.1.4 vendor/bundle/ruby/2.4.0/gems/yard-0.9.8/templates/default/docstring/setup.rb
etude_for_ruby-0.1.4 vendor/bundle/ruby/2.2.0/gems/yard-0.9.8/templates/default/docstring/setup.rb
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/yard-0.9.8/templates/default/docstring/setup.rb
yard-0.9.8 templates/default/docstring/setup.rb
abaci-0.3.0 vendor/bundle/gems/yard-0.9.7/templates/default/docstring/setup.rb
yard-0.9.7 templates/default/docstring/setup.rb
yard-0.9.6 templates/default/docstring/setup.rb