Class: YARD::CodeObjects::MethodObject
- Inherits:
-
Object
- Object
- YARD::CodeObjects::MethodObject
- Defined in:
- lib/puppet_x/puppetlabs/strings/yard/code_objects/method_object.rb
Instance Method Summary collapse
- #to_json(*a) ⇒ Object
-
#to_s ⇒ Object
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.
Instance Method Details
#to_json(*a) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# 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..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..map do |tag| tag.text if tag.tag_name == 'example' end.compact, }.to_json(*a) else super end end |
#to_s ⇒ Object
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.
5 6 7 8 9 10 11 |
# 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 |