Method: YARD::CodeObjects::Base#format

Defined in:
lib/yard/code_objects/base.rb

#format(options = {}) ⇒ String

Renders the object using the templating system.

Examples:

Formats a class in plaintext

puts P('MyClass').format

Formats a method in html with rdoc markup

puts P('MyClass#meth').format(:format => :html, :markup => :rdoc)

Parameters:

  • options (Hash) (defaults to: {})

    a set of options to pass to the template

Options Hash (options):

  • :format (Symbol) — default: :text

    :html, :text or another output format

  • :template (Symbol) — default: :default

    a specific template to use

  • :markup (Symbol) — default: nil

    the markup type (:rdoc, :markdown, :textile)

  • :serializer (Serializers::Base) — default: nil

    see Serializers

Returns:

  • (String)

    the rendered template

See Also:

  • Templates::Engine#render


505
506
507
508
509
# File 'lib/yard/code_objects/base.rb', line 505

def format(options = {})
  options = options.merge(:object => self)
  options = options.merge(:type => type) unless options[:type]
  Templates::Engine.render(options)
end