Class: JsDuck::Source::FileParser

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

Overview

Performs the actual parsing of CSS or JS source.

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

Instance Method Summary collapse

Constructor Details

#initializeFileParser

Returns a new instance of FileParser.



19
20
21
22
23
24
25
# File 'lib/jsduck/source/file_parser.rb', line 19

def initialize
  @doc_type = DocType.new
  @doc_parser = DocParser.new
  @class_doc_expander = ClassDocExpander.new
  @doc_ast = DocAst.new
  @merger = Merger.new
end

Instance Method Details

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

Parses file into final docset that can be fed into Aggregator



28
29
30
31
32
33
34
35
36
# File 'lib/jsduck/source/file_parser.rb', line 28

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

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