class YARD::CodeObjects::MethodObject

Public Instance Methods

to_json(*a) click to toggle source
Calls superclass method
# File lib/puppet_x/puppetlabs/strings/yard/code_objects/method_object.rb, line 13
def to_json(*a)
  if self[:puppet_4x_function]
    {
      "name"                  => @name,
      "file"                  => file,
      "line"                  => line,
      "function_api_version"  => 4,
      "docstring"             => Puppet::Util::Docs.scrub(@docstring),
      "examples"              => self.tags.map do |tag|
          tag.text if tag.tag_name == 'example'
        end.compact,
      "documented_params"     => @parameters.map do |tuple|
        {
          "name" => tuple[0],
          "type" => tuple[1],
        }
      end,
     "signatures"       => @type_info.map do |signature|
        signature.map do |key, value|
          {
            "name" => key,
            "type" => value,
          }
        end
      end,
    }.to_json(*a)
  elsif self[:puppet_3x_function]
    {
      "name"                  => @name,
      "file"                  => file,
      "line"                  => line,
      "function_api_version"  => 3,
      "docstring"             => Puppet::Util::Docs.scrub(@docstring),
      "documented_params"     => @parameters.map do |tuple|
        {
          "name" => tuple[0],
          "type" => tuple[1],
        }
      end,
      "examples"              => self.tags.map do |tag|
          tag.text if tag.tag_name == 'example'
        end.compact,
    }.to_json(*a)
  else
    super
  end
end
to_s() click to toggle source

Override #to_s and #to_json methods in Yard's MethodObject so that they return output formatted as I like for puppet 3x and 4x methods.

Calls superclass method
# File lib/puppet_x/puppetlabs/strings/yard/code_objects/method_object.rb, line 5
def to_s
  if self[:puppet_4x_function] || self[:puppet_3x_function]
    name.to_s
  else
    super
  end
end