Sha256: d69f062b28067d501b7b0f6a432a4a07dd76a0b122be048c992d782d96b67552

Contents?: true

Size: 1.35 KB

Versions: 12

Compression:

Stored size: 1.35 KB

Contents

def init
  super

  sections *[
    :emits,
    :note,
    :warning,
    :argument,
    :request_field,
    :response_field,
    :example_request,
    :example_response,
    :throws,
    :see,
    :returns,
    :no_content,
  ]
end

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

def request_field
  generic_tag :request_field
end

def response_field
  generic_tag :response_field
end

def throws
  @error_tags = object.tags(:throws)

  if @error_tags.any?
    erb('throws')
  end
end

def emits
  @emits = object.tags(:emits)

  if @emits.any?
    erb('emits')
  end
end

def argument
  argument_tags = object.tags(:argument)

  if argument_tags.any?
    options[:argument_tags] = argument_tags
    erb('argument')
  end
end

def returns
  return unless object.has_tag?(:returns)
  response_info = object.tag(:returns)
  case response_info.text
  when %r{\[(.*)\]}
    @object_name = $1.strip
    @is_list = true
  else
    @object_name = response_info.text.strip
    @is_list = false
  end

  @resource_name = options[:json_objects_map][@object_name]
  return unless @resource_name
  erb(:returns)
end

def generic_tag(name, opts = {})
  return unless object.has_tag?(name)
  @no_names = true if opts[:no_names]
  @no_types = true if opts[:no_types]
  @label = opts[:label]
  @name = name
  out = erb('generic_tag')
  @no_names, @no_types = nil, nil
  out
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
yard-api-1.1.2 templates/api/tags/setup.rb
yard-api-1.1.1 templates/api/tags/setup.rb
yard-api-1.1.0 templates/api/tags/setup.rb
yard-api-1.0.1 templates/api/tags/setup.rb
yard-api-1.0.0 templates/api/tags/setup.rb
yard-api-0.3.7 templates/api/tags/setup.rb
yard-api-0.3.6 templates/api/tags/setup.rb
yard-api-0.3.5 templates/api/tags/setup.rb
yard-api-0.3.4 templates/api/tags/setup.rb
yard-api-0.3.3 templates/api/tags/setup.rb
yard-api-0.3.2 templates/api/tags/setup.rb
yard-api-0.3.1 templates/api/tags/setup.rb