Class: JsDuck::Doc::DelimitedParser

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

Overview

Helper in parsing the default values and type definitions where we take into account correctly nested parenthesis and strings. But at the same time we don’t care much about the actual contents.

Instance Method Summary collapse

Constructor Details

#initialize(doc_scanner) ⇒ DelimitedParser

Initialized with Doc::Scanner instance



10
11
12
# File 'lib/jsduck/doc/delimited_parser.rb', line 10

def initialize(doc_scanner)
  @ds = doc_scanner
end

Instance Method Details

#parse_until_close_curlyObject

Parses until a closing “}”.



15
16
17
# File 'lib/jsduck/doc/delimited_parser.rb', line 15

def parse_until_close_curly
  parse_until_close_paren(/\}/, /[^\}]*/)
end

#parse_until_close_squareObject

Parses until a closing “]”.



20
21
22
# File 'lib/jsduck/doc/delimited_parser.rb', line 20

def parse_until_close_square
  parse_until_close_paren(/\]/, /[^\]]*/)
end

#parse_until_spaceObject

Parses until a closing parenthesis or space.



25
26
27
28
29
30
31
# File 'lib/jsduck/doc/delimited_parser.rb', line 25

def parse_until_space
  begin
    parse_while(/[^\[\]\{\}\(\)'"\s]/)
  rescue
    nil
  end
end