Module: YARD::Markdown::MethodPresentationHelper
- Defined in:
- lib/yard/markdown/method_presentation_helper.rb
Overview
Formats method and attribute names for Markdown headings.
Class Method Summary collapse
-
.attribute_access(attribute) ⇒ String
Returns the access marker for an attribute.
-
.formatted_method_heading(method_object) ⇒ String
Builds the display heading for a method.
-
.method_signature(method_object) ⇒ String
Returns the rendered parameter list for a method.
Class Method Details
.attribute_access(attribute) ⇒ String
Returns the access marker for an attribute.
34 35 36 37 38 39 40 |
# File 'lib/yard/markdown/method_presentation_helper.rb', line 34 def self.attribute_access(attribute) read, write = attribute.attr_info.fetch_values(:read, :write) return "RW" if read && write return "R" if read "W" end |
.formatted_method_heading(method_object) ⇒ String
Builds the display heading for a method.
11 12 13 14 15 16 |
# File 'lib/yard/markdown/method_presentation_helper.rb', line 11 def self.formatted_method_heading(method_object) name = method_object.name signature = method_signature(method_object) signature = " #{signature}" if name.end_with?("]") "#{name}#{signature}" end |
.method_signature(method_object) ⇒ String
Returns the rendered parameter list for a method.
22 23 24 25 26 27 28 |
# File 'lib/yard/markdown/method_presentation_helper.rb', line 22 def self.method_signature(method_object) rendered = Array(method_object.parameters).map do |name, default| default.to_s.empty? ? name : "#{name} = #{default}" end "(#{rendered.join(", ")})" end |