class JsDuck::Doc::Processor

Processes @tag data detected from doc-comment, transforming it into a class/member hash which can be then later further merged with code hash.

Its main work is done through calling the process_doc method of all the Tag classes that have registered themselves to process a particular set of @tags through defining a .tagname attribute.

Attributes

filename[RW]

Allow passing in filename and line for error reporting

linenr[RW]

Public Class Methods

new() click to toggle source
# File lib/jsduck/doc/processor.rb, line 18
def initialize
  @filename = ""
  @linenr = 0
end

Public Instance Methods

process(tagname, doc_map) click to toggle source

Given tagname and map of tags from DocParser, produces docs of the type determined by tagname.

# File lib/jsduck/doc/processor.rb, line 25
def process(tagname, doc_map)
  hash = {
    :tagname => tagname,
    :doc => extract_doc(doc_map),
  }

  position = {:filename => @filename, :linenr => @linenr}

  doc_map.each_pair do |name, value|
    if tag = TagRegistry.get_by_name(name)
      tag.process_doc(hash, value, position)
    end
  end

  return hash
end

Private Instance Methods

extract_doc(doc_map) click to toggle source
# File lib/jsduck/doc/processor.rb, line 44
def extract_doc(doc_map)
  tag = doc_map[:doc] ? doc_map[:doc].first : {}
  return tag[:doc] || ""
end