Class: Stylesheet

Inherits:
Object
  • Object
show all
Defined in:
app/models/stylesheet.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Stylesheet

Returns a new instance of Stylesheet.



2
3
4
5
# File 'app/models/stylesheet.rb', line 2

def initialize(options)
  @file_path = options[:file_path]
  @css = options[:css]
end

Instance Method Details

#parseObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/models/stylesheet.rb', line 7

def parse
  documentation = []

  styleguide_comments.each do |comment|
    comment = comment[1]

    name = find_name_for(comment)
    section = find_section_for(comment)
    description = find_description_for(comment)
    example = find_example_for(comment)
    url = find_url_for(comment)

    if name.present? || section.present? || description.present? || example.present? || url.present?
      component = Component.new

      component.source = @file_path

      component.name = name if name
      if section
        component.section = section
      else
        component.section = name
      end

      component.description = description if description
      component.example = example if example
      component.url = url if url

      documentation << component
    end
  end
  group_by_section(documentation)
end