Method: YARD::Templates::Helpers::HtmlHelper#format_types

Defined in:
lib/yard/templates/helpers/html_helper.rb

#format_types(typelist, brackets = true) ⇒ String

Formats a list of types from a tag.

Parameters:

  • typelist (Array<String>, FalseClass)

    the list of types to be formatted.

  • brackets (Boolean) (defaults to: true)

    omits the surrounding brackets if brackets is set to false.

Returns:

  • (String)

    the list of types formatted as [Type1, Type2, …] with the types linked to their respective descriptions.

[View source]

372
373
374
375
376
377
378
379
380
# File 'lib/yard/templates/helpers/html_helper.rb', line 372

def format_types(typelist, brackets = true)
  return unless typelist.is_a?(Array)
  list = typelist.map do |type|
    type = type.gsub(/([<>])/) { h($1) }
    type = type.gsub(/([\w:]+)/) { $1 == "lt" || $1 == "gt" ? $1 : linkify($1, $1) }
    "<tt>" + type + "</tt>"
  end
  list.empty? ? "" : (brackets ? "(#{list.join(", ")})" : list.join(", "))
end