Method: JsDuck::DocParser#parse

Defined in:
lib/jsduck/doc_parser.rb

#parse(input, filename = "", linenr = 0) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/jsduck/doc_parser.rb', line 32

def parse(input, filename="", linenr=0)
  @filename = filename
  @linenr = linenr
  @tags = []
  @input = StringScanner.new(purify(input))
  parse_loop
  # The parsing process can leave whitespace at the ends of
  # doc-strings, here we get rid of it.  Additionally null all empty docs
  @tags.each do |tag|
    tag[:doc].strip!
    tag[:doc] = nil if tag[:doc] == ""
  end
  # Get rid of empty default tag
  if @tags.first && @tags.first[:tagname] == :default && !@tags.first[:doc]
    @tags.shift
  end
  @tags
end