class JsDuck::Format::Class

Performs documentation formatting of a class and all of its members.

The actual work is delegated to the format methods of Tag classes, to which we pass the Format::Doc instance which they can use to perform the formatting.

The formatting done by format methods usually consists of turning :doc properties of class from markdown to HTML, resolving @links, and converting type definitions to HTML.

Public Class Methods

new(formatter) click to toggle source
# File lib/jsduck/format/class.rb, line 17
def initialize(formatter)
  @formatter = formatter
end

Public Instance Methods

format(cls) click to toggle source

Runs the formatter on doc object of a class. Accessed using Class#internal_doc

# File lib/jsduck/format/class.rb, line 23
def format(cls)
  @formatter.class_context = cls[:name]
  @formatter.doc_context = cls[:files][0]

  format_tags(cls)

  # format all members (except hidden ones)
  cls[:members].each {|m| format_member(m) unless m[:hide] }

  cls
end
images() click to toggle source

Access to the Img::DirSet object inside doc-formatter

# File lib/jsduck/format/class.rb, line 36
def images
  @formatter.images
end

Private Instance Methods

format_member(m) click to toggle source
# File lib/jsduck/format/class.rb, line 42
def format_member(m)
  @formatter.doc_context = m[:files][0]

  # Turn off type parsing for SCSS vars and mixins
  @formatter.skip_type_parsing = [:css_var, :css_mixin].include?(m[:tagname])

  format_tags(m)
end
format_tags(context) click to toggle source
# File lib/jsduck/format/class.rb, line 51
def format_tags(context)
  Render::Tags.renderers.each do |tag|
    if context[tag.tagname]
      tag.format(context, @formatter)
    end
  end
end