Class: JsDuck::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/jsduck/parser.rb

Overview

Performs the actual parsing of SCSS or JS source.

This is the class that brings together all the different steps of parsing the source.

Instance Method Summary collapse

Constructor Details

#initializeParser

Returns a new instance of Parser.



18
19
20
21
22
23
24
# File 'lib/jsduck/parser.rb', line 18

def initialize
  @doc_parser = Doc::Parser.new
  @class_doc_expander = ClassDocExpander.new
  @doc_processor = Doc::Processor.new
  @merger = Merger.new
  @filename = ""
end

Instance Method Details

#parse(contents, filename = "", options = {}) ⇒ Object

Parses file into final docset that can be fed into Aggregator



27
28
29
30
31
32
33
34
35
# File 'lib/jsduck/parser.rb', line 27

def parse(contents, filename="", options={})
  @doc_processor.filename = @filename = filename

  parse_js_or_scss(contents, filename, options).map do |docset|
    expand(docset)
  end.flatten.map do |docset|
    merge(docset)
  end
end