Sha256: 8f90b246c25bca29d3f75f392539f8bf6afe8433b0a2720068e431f27d4e2bb7
Contents?: true
Size: 1.24 KB
Versions: 5
Compression:
Stored size: 1.24 KB
Contents
module YARD module Generators::Helpers module MethodHelper def format_args(object) unless object.parameters.empty? args = object.parameters.map {|n, v| v ? "#{n} = #{v}" : n.to_s }.join(", ") h("(#{args})") else "" end end def format_return_types(object) return unless object.has_tag?(:return) && object.tag(:return).types return if object.tag(:return).types.empty? format_types [object.tag(:return).types.first], false end def format_block(object) if object.has_tag?(:yieldparam) h "{|" + object.tags(:yieldparam).map {|t| t.name }.join(", ") + "| ... }" else "" end end def format_lines(object) i = -1 object.source.split(/\n/).map { object.line + (i += 1) }.join("\n") end def format_code(object, show_lines = false) i = -1 lines = object.source.split(/\n/) longestline = (object.line + lines.size).to_s.length lines.map do |line| lineno = object.line + (i += 1) (" " * (longestline - lineno.to_s.length)) + lineno.to_s + " " + line end.join("\n") end end end end
Version data entries
5 entries across 5 versions & 1 rubygems