Module: YARD::Markdown::MethodPresentationHelper
- Defined in:
- lib/yard/markdown/method_presentation_helper.rb
Overview
Formats method and attribute names for Markdown headings.
Instance 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.
Instance Method Details
#attribute_access(attribute) ⇒ String
Returns the access marker for an attribute.
36 37 38 39 40 41 42 |
# File 'lib/yard/markdown/method_presentation_helper.rb', line 36 def 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 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 29 30 |
# File 'lib/yard/markdown/method_presentation_helper.rb', line 22 def method_signature(method_object) return "()" if method_object.parameters.nil? rendered = method_object.parameters.map do |name, default| (default.nil? || default.empty?) ? name : "#{name} = #{default}" end "(#{rendered.join(", ")})" end |