vivus 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e91f68c5d5976fc293b0ddc92a60dee74a50ed96
4
- data.tar.gz: abdb3ddeea7a3354350d403d518be53d1fb9f336
3
+ metadata.gz: b185bf25bd7e7ba47b047943c0456c2f82e271b3
4
+ data.tar.gz: 8429dc067fd83b962aed851a24cd451c3d60b626
5
5
  SHA512:
6
- metadata.gz: dfad9b9bf091e40c0bb2650ec29d5d87d140a0cf06a3def21013a4c08ba7d2350ce2ac8bab6841088884a3d06698e06876af9faf5165dd4c0119611d90b25ba4
7
- data.tar.gz: 5a6ae28163548adf7022ad5053bdf54c01c589b449ef58b51bd07cb3a9ed8ee2cc65469a378b74fe2daed42e3fa6e436babf5c96be84404d815d6e217ec6d72d
6
+ metadata.gz: fc3e6369648090da445ccbd0342e723dc9fd0d88aa3164f97acab5b9d0f9dcef0ae359742e08c07d18797484410b9ecf0c58c5988c120b46335b142509d535c7
7
+ data.tar.gz: b2b0d125f085af2359d257a9eb998d88bcaa518ef363e08ed4634ccea8adc042c500dabbcc6c3f1d7b664535972461039d58d8ae3ba10038dcc409c864331fa2
@@ -9,7 +9,7 @@ $(document).ready(function() {
9
9
  });
10
10
 
11
11
  $('h2.vivus-name').each(function(i, el) {
12
- $(el).before("<a name='" + $(el).text().toLowerCase().replace(/ /g, '-') +"'></a>");
12
+ $(el).before("<a name='" + $(el).text().toLowerCase().replace(',', '').replace(/ /g, '-') +"'></a>");
13
13
  })
14
14
 
15
15
  $('.vivus-documentation *:contains("TODO:")').html(function(_, html) {
@@ -50,6 +50,11 @@ li.vivus-component {
50
50
  }
51
51
 
52
52
  .vivus-code {
53
+ > em.vivus-source {
54
+ padding: 10px;
55
+ color: #bbb;
56
+ }
57
+
53
58
  > pre {
54
59
  font-family: monospace;
55
60
  word-wrap: break-word;
@@ -43,6 +43,12 @@
43
43
  margin-left: 0;
44
44
  padding-left: 15px;
45
45
  border-left: 5px solid #F3DF6C;
46
+
47
+ ul {
48
+ li {
49
+ display: block;
50
+ }
51
+ }
46
52
  }
47
53
 
48
54
  a {
@@ -51,8 +57,11 @@
51
57
 
52
58
  ul {
53
59
  margin-top: 10px;
54
- }
55
60
 
61
+ li {
62
+ display: none;
63
+ }
64
+ }
56
65
 
57
66
  .h2 {
58
67
  font-size: 13px;
@@ -11,26 +11,18 @@ class Vivus::StylesController < Vivus::ApplicationController
11
11
  private
12
12
 
13
13
  def gather_stylesheets
14
+
14
15
  sprockets = Rails.application.assets
15
16
 
16
17
  @css_paths = %w{application.css}
17
- @css_paths += Rails.application.config.assets.precompile.select { |item|
18
+ @css_paths += Rails.application.config.assets.precompile.select do |item|
18
19
  item.is_a?(String) && item[-4,4] == ".css"
19
- }
20
-
21
- @stylesheets = @css_paths
22
- .map{|file_path| Stylesheet.new(css: sprockets[file_path].body)}
23
- .map{|stylesheet| stylesheet.parse}
24
- .reject{|stylesheet| stylesheet.empty?}
25
- .inject({}){ | accum, data |
26
- data.each do |section, components|
27
- accum[section] ||= []
28
- accum[section] += components
29
- end
30
-
31
- accum
32
- }
33
20
  end
21
+ stylesheets = @css_paths.map{|file_path| Stylesheet.new(file_path: file_path, css: sprockets[file_path].body)}
22
+
23
+ styleguide = Styleguide.new(stylesheets: stylesheets)
24
+ @stylesheets = styleguide.generate
25
+ end
34
26
 
35
27
  def is_a_file? file
36
28
  File.file?(file)
@@ -1,7 +1,7 @@
1
1
  require 'rdiscount'
2
2
 
3
3
  class Component
4
- attr_accessor :name, :section, :description, :example, :url
4
+ attr_accessor :name, :section, :description, :example, :url, :source
5
5
 
6
6
  def display_description
7
7
  RDiscount.new(self.description, :smart, :filter_html).to_html.html_safe if self.description
@@ -0,0 +1,21 @@
1
+ # Takes a bunch of Stylesheets, parses them,
2
+ # and merges them into a single styleguide.
3
+ class Styleguide
4
+ def initialize(options)
5
+ @stylesheets = options[:stylesheets]
6
+ end
7
+
8
+ def generate
9
+ @stylesheets
10
+ .map{|stylesheet| stylesheet.parse}
11
+ .reject{|stylesheet| stylesheet.empty?}
12
+ .inject({}){ | accum, data |
13
+ data.each do |section, components|
14
+ accum[section] ||= []
15
+ accum[section] += components
16
+ end
17
+
18
+ accum
19
+ }
20
+ end
21
+ end
@@ -1,15 +1,13 @@
1
- require 'yaml'
2
-
3
-
4
1
  class Stylesheet
5
2
  def initialize(options)
3
+ @file_path = options[:file_path]
6
4
  @css = options[:css]
7
5
  end
8
6
 
9
7
  def parse
10
8
  documentation = []
11
9
 
12
- styleguide_comment.each do |comment|
10
+ styleguide_comments.each do |comment|
13
11
  comment = comment[1]
14
12
 
15
13
  name = find_name_for(comment)
@@ -21,6 +19,8 @@ class Stylesheet
21
19
  if name.present? || section.present? || description.present? || example.present? || url.present?
22
20
  component = Component.new
23
21
 
22
+ component.source = @file_path
23
+
24
24
  component.name = name if name
25
25
  if section
26
26
  component.section = section
@@ -86,7 +86,7 @@ class Stylesheet
86
86
  end
87
87
  end
88
88
 
89
- def styleguide_comment
89
+ def styleguide_comments
90
90
  regex = /\/\*\*(.*?)\*\*\//m
91
91
  scan_comment(@css, regex)
92
92
  end
@@ -4,7 +4,15 @@
4
4
  <title>Vivus</title>
5
5
  <%= stylesheet_link_tag "vivus/application", :media => "all" %>
6
6
  <%= javascript_include_tag "vivus/application" %>
7
- <%= stylesheet_link_tag "application", :media => "all" %>
7
+
8
+ <% @css_paths.each do |path| %>
9
+ <% if path.match(/print/).nil? %>
10
+ <%= stylesheet_link_tag path, :media => "all" %>
11
+ <% else %>
12
+ <%= stylesheet_link_tag path, :media => "print" %>
13
+ <% end %>
14
+ <% end %>
15
+
8
16
  <%= csrf_meta_tags %>
9
17
  </head>
10
18
  <body id="vivus">
@@ -16,6 +16,7 @@
16
16
  </div>
17
17
 
18
18
  <div class="vivus-code vivus-block ">
19
+ <em class="vivus-source">From <%= component.source %></em>
19
20
  <pre><%= component.display_example %></pre>
20
21
  </div>
21
22
  <% end %>
@@ -3,16 +3,16 @@
3
3
  <% @stylesheets.each do |group| %>
4
4
  <% section = group[0] %>
5
5
  <% section_slug = section.downcase.gsub(/[^a-z1-9]+/, '-').chomp('-') %>
6
- <% chunks = group[1] %>
6
+ <% components = group[1] %>
7
7
 
8
8
  <li class="h1 <%= "active" if section.downcase.gsub(/[^a-z1-9]+/, '-').chomp('-') == params[:section] %>">
9
9
  <%= link_to section, vivus_section_path(section_slug) %>
10
10
 
11
- <% if chunks.present? %>
11
+ <% if components.present? %>
12
12
  <ul>
13
- <% chunks.each do |chunk| %>
13
+ <% components.each do |component| %>
14
14
  <li class="h2">
15
- <%= link_to chunk.name, vivus_section_path(section_slug, anchor: chunk.slug) %>
15
+ <%= link_to component.name, vivus_section_path(section_slug, anchor: component.slug) %>
16
16
  </li>
17
17
  <% end %>
18
18
  </ul>
@@ -8,7 +8,7 @@
8
8
  <p>Above each block of code in your CSS, start documenting your styleguide by writing comments.</p>
9
9
  <p>Use the below example as a starting point.</p>
10
10
  <pre>
11
- /*
11
+ /**
12
12
  [Name] The name of the component (e.g. Success Buttons)
13
13
  [Section] A section that groups components together (e.g. Buttons)
14
14
  [Description]
@@ -32,7 +32,7 @@ need be.
32
32
  &lt;a href="#" class="button"&gt;Some text&lt;a&gt;
33
33
  &lt;/div&gt;
34
34
  [Url] A web address pointing to further documentation / example (optional)
35
- */
35
+ **/
36
36
  </pre>
37
37
  </li>
38
38
  </ul>
data/lib/vivus/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Vivus
2
- VERSION = "1.0.7"
2
+ VERSION = "1.0.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vivus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Cipolla
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-13 00:00:00.000000000 Z
11
+ date: 2014-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: '4'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '5'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '4.0'
29
+ version: '4'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '5'
@@ -57,9 +57,6 @@ dependencies:
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
59
  version: '2.14'
60
- - - "<"
61
- - !ruby/object:Gem::Version
62
- version: '3'
63
60
  type: :development
64
61
  prerelease: false
65
62
  version_requirements: !ruby/object:Gem::Requirement
@@ -67,9 +64,6 @@ dependencies:
67
64
  - - ">="
68
65
  - !ruby/object:Gem::Version
69
66
  version: '2.14'
70
- - - "<"
71
- - !ruby/object:Gem::Version
72
- version: '3'
73
67
  description: Styleguides can be a pain to keep as a living documentation for your
74
68
  CSS. By analysing the comments in your SASS files, and by adding markdown to your
75
69
  stylesheets, you can generate a living, breathing documentation styleguide that
@@ -95,6 +89,7 @@ files:
95
89
  - app/controllers/vivus/application_controller.rb
96
90
  - app/controllers/vivus/styles_controller.rb
97
91
  - app/models/component.rb
92
+ - app/models/styleguide.rb
98
93
  - app/models/stylesheet.rb
99
94
  - app/views/layouts/vivus/application.html.erb
100
95
  - app/views/vivus/styles/_component.html.erb