Sha256: 59aea4d61ffa70561fa89416615639a87d1bb7305bd2ef2717db1c2b9a7868a4

Contents?: true

Size: 863 Bytes

Versions: 3

Compression:

Stored size: 863 Bytes

Contents

require_relative "base_parser.rb"

module Docks
  module Parsers
    class Stylus < Sass
      def initialize
        @comment_pattern = /(?:\/\/|\/\*!?|\*\/?)/
        @first_non_code_line_pattern = /[=+\.#\w\[&@]/
        setup_regexes
      end

      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
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
docks_app-0.0.3 lib/docks/parsers/stylus_parser.rb
docks_app-0.0.2 lib/docks/parsers/stylus_parser.rb
docks_app-0.0.1 lib/docks/parsers/stylus_parser.rb