Class: Docks::Parsers::Less

Inherits:
Sass show all
Defined in:
lib/docks/parsers/less_parser.rb

Instance Attribute Summary

Attributes inherited from Base

#comment_line_pattern, #comment_pattern, #pattern_block_extractor, #symbol_block_extractor

Instance Method Summary collapse

Methods inherited from Sass

#initialize

Methods inherited from Base

#initialize, #parse, #parse_comment_block

Constructor Details

This class inherits a constructor from Docks::Parsers::Sass

Instance Method Details

#symbol_details_from_first_line(first_code_line) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/docks/parsers/less_parser.rb', line 6

def symbol_details_from_first_line(first_code_line)
  first_code_line.strip!

  type = case first_code_line
    when /^.[^\(]*\(/ then Docks::Types::Symbol::MIXIN
    when /^@/ then Docks::Types::Symbol::VARIABLE
    when /(\.|\-\-)?(?:is|js)\-/ then Docks::Types::Symbol::STATE
    when /\-\-(?:[a-zA-Z][\-_]?)*/ then Docks::Types::Symbol::VARIANT
    else Docks::Types::Symbol::COMPONENT
  end

  name = first_code_line.match(/^\s*&?[\.#]?\s*(@?[^\s\(\:]*)/).captures.first
  { name: name, symbol_type: type }
end