kss 0.4.0 → 0.5.0
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 +7 -0
- data/README.md +45 -2
- data/lib/kss.coffee +25 -8
- data/lib/kss/comment_parser.rb +53 -41
- data/lib/kss/parser.rb +25 -13
- data/lib/kss/section.rb +4 -4
- data/lib/kss/version.rb +1 -1
- data/test/fixtures/css/buttons.css +31 -0
- data/test/fixtures/css/images/example.png +0 -0
- data/test/fixtures/less/buttons.less +17 -1
- data/test/fixtures/sass/buttons.sass +12 -0
- data/test/fixtures/scss/buttons.scss +15 -1
- data/test/helper.rb +2 -3
- data/test/parser_test.rb +58 -53
- data/test/section_test.rb +6 -0
- metadata +18 -14
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1e5a7828fb96863926b68b29f71602747e9b3dec
|
4
|
+
data.tar.gz: 0a5e39cafe9a7d94171be7101c60059ab7570838
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ebe249b7652df9e6b50d26a958b1a9195ed3d83936d19a67808a549a80c4885042cbd242e37bf330cdc0ac6cad049de266b04c7b66bb3bc784bed08582182250
|
7
|
+
data.tar.gz: efc8616414baafa51a686f45bce4e2544fe4d5b1d3b292620f54e431f22eb8382ad2d0b5aa76bb123fe69fa4b51ff2520e76dc87fbfd8039644b8dd4d9e077e9
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ Inspired by [TomDoc](http://tomdoc.org), KSS attempts to provide a methodology f
|
|
7
7
|
|
8
8
|
## KSS in a nutshell
|
9
9
|
|
10
|
-
The methodology and ideas behind Knyle Style Sheets are contained in [SPEC.md](https://github.com/kneath/kss/blob/master/SPEC.md). At
|
10
|
+
The methodology and ideas behind Knyle Style Sheets are contained in [SPEC.md](https://github.com/kneath/kss/blob/master/SPEC.md). At its core, KSS is a documenting syntax for CSS.
|
11
11
|
|
12
12
|
```css
|
13
13
|
/*
|
@@ -31,7 +31,14 @@ a.button.star.disabled{
|
|
31
31
|
}
|
32
32
|
```
|
33
33
|
|
34
|
-
|
34
|
+
KSS can also support words as Styleguide section names
|
35
|
+
```scss
|
36
|
+
// Styleguide Forms.Checkboxes.
|
37
|
+
// - or -
|
38
|
+
// Styleguide Forms - Special Checkboxes.
|
39
|
+
```
|
40
|
+
|
41
|
+
## Ruby Library [](https://travis-ci.org/kneath/kss) [](https://codeclimate.com/github/kneath/kss)
|
35
42
|
|
36
43
|
This repository includes a ruby library suitable for parsing SASS, SCSS, and CSS documented with KSS guidelines. To use the library, include it in your project as a gem from <https://rubygems.org/gems/kss>. Then, create a parser and explore your KSS.
|
37
44
|
|
@@ -55,7 +62,38 @@ styleguide.section('2.1.1').modifiers.first.class_name
|
|
55
62
|
|
56
63
|
styleguide.section('2.1.1').modifiers.first.description
|
57
64
|
# => 'Subtle hover highlight'
|
65
|
+
```
|
58
66
|
|
67
|
+
You can also initialize the `Kss::Parser` with a string CSS by using `Kss::Parser.new(string)`
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
buttons =<<-'EOS'
|
71
|
+
/*
|
72
|
+
Your standard form button.
|
73
|
+
|
74
|
+
:hover - Highlights when hovering.
|
75
|
+
:disabled - Dims the button when disabled.
|
76
|
+
|
77
|
+
Styleguide 1.1
|
78
|
+
*/
|
79
|
+
button {
|
80
|
+
padding: 5px 15px;
|
81
|
+
line-height: normal;
|
82
|
+
/* ... */
|
83
|
+
}
|
84
|
+
button:disabled {
|
85
|
+
opacity: 0.5;
|
86
|
+
}
|
87
|
+
EOS
|
88
|
+
styleguide = Kss::Parser.new(buttons)
|
89
|
+
|
90
|
+
styleguide.section('1.1')
|
91
|
+
# => <Kss::Section>
|
92
|
+
|
93
|
+
styleguide.section('1.1.1').description
|
94
|
+
# => "Your standard form button."
|
95
|
+
|
96
|
+
# ...
|
59
97
|
```
|
60
98
|
|
61
99
|
The library is also fully TomDoc'd, completing the circle of life.
|
@@ -76,3 +114,8 @@ To hack on KSS, you'll need to install dependencies with `bundle install`. Run t
|
|
76
114
|
To make your life easier, I suggest `bundle install --binstubs` and adding `bin/` to your `$PATH`. If you don't understand this, just blindly add `bundle exec` in front of everything you'd normally do, like `bundle exec rake`.
|
77
115
|
|
78
116
|
I apologize on behalf of the Ruby community for this, it's embarrassing and disappointing that dependency management is still so clumsy.
|
117
|
+
|
118
|
+
## Implementations
|
119
|
+
|
120
|
+
The KSS specification has also been implemented in [Python](https://github.com/seanbrant/pykss), [Node.js](https://github.com/hughsk/kss-node) and [PHP](https://github.com/scaninc/kss-php)
|
121
|
+
|
data/lib/kss.coffee
CHANGED
@@ -1,24 +1,41 @@
|
|
1
1
|
# This class scans your stylesheets for pseudo classes, then inserts a new CSS
|
2
2
|
# rule with the same properties, but named 'psuedo-class-{{name}}'.
|
3
3
|
#
|
4
|
-
# Supported pseudo classes: hover, disabled, active, visited, focus.
|
4
|
+
# Supported pseudo classes: hover, disabled, active, visited, focus, target.
|
5
5
|
#
|
6
6
|
# Example:
|
7
7
|
#
|
8
8
|
# a:hover{ color:blue; }
|
9
9
|
# => a.pseudo-class-hover{ color:blue; }
|
10
10
|
class KssStateGenerator
|
11
|
+
psuedo_selectors = [
|
12
|
+
'hover',
|
13
|
+
'enabled',
|
14
|
+
'disabled',
|
15
|
+
'active',
|
16
|
+
'visited',
|
17
|
+
'focus',
|
18
|
+
'target',
|
19
|
+
'checked',
|
20
|
+
'empty',
|
21
|
+
'first-of-type',
|
22
|
+
'last-of-type',
|
23
|
+
'first-child',
|
24
|
+
'last-child']
|
25
|
+
|
11
26
|
constructor: ->
|
12
|
-
pseudos =
|
27
|
+
pseudos = new RegExp "(\\:#{psuedo_selectors.join('|\\:')})", "g"
|
13
28
|
|
14
29
|
try
|
15
30
|
for stylesheet in document.styleSheets
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
31
|
+
if stylesheet.href.indexOf(document.domain) >= 0
|
32
|
+
idxs = []
|
33
|
+
for rule, idx in stylesheet.cssRules
|
34
|
+
if (rule.type == CSSRule.STYLE_RULE) && pseudos.test(rule.selectorText)
|
35
|
+
replaceRule = (matched, stuff) ->
|
36
|
+
return matched.replace(/\:/g, '.pseudo-class-')
|
37
|
+
@insertRule(rule.cssText.replace(pseudos, replaceRule))
|
38
|
+
pseudos.lastIndex = 0
|
22
39
|
|
23
40
|
# Takes a given style and attaches it to the current page.
|
24
41
|
#
|
data/lib/kss/comment_parser.rb
CHANGED
@@ -58,15 +58,19 @@ module Kss
|
|
58
58
|
# Public: Initializes a new comment parser object. Does not parse on
|
59
59
|
# initialization.
|
60
60
|
#
|
61
|
-
#
|
62
|
-
# options
|
61
|
+
# file_path_or_string_input - The location of the file to parse as a String, or the String itself.
|
62
|
+
# options - Optional options hash.
|
63
63
|
# :preserve_whitespace - Preserve the whitespace before/after comment
|
64
64
|
# markers (default:false).
|
65
65
|
#
|
66
|
-
def initialize(
|
66
|
+
def initialize(file_path_or_string_input, options={})
|
67
67
|
@options = options
|
68
68
|
@options[:preserve_whitespace] = false if @options[:preserve_whitespace].nil?
|
69
|
-
|
69
|
+
if File.exists?(file_path_or_string_input)
|
70
|
+
@file_path = file_path_or_string_input
|
71
|
+
else
|
72
|
+
@string_input = file_path_or_string_input
|
73
|
+
end
|
70
74
|
@blocks = []
|
71
75
|
@parsed = false
|
72
76
|
end
|
@@ -80,52 +84,60 @@ module Kss
|
|
80
84
|
@parsed ? @blocks : parse_blocks
|
81
85
|
end
|
82
86
|
|
83
|
-
|
84
|
-
# Parse the file for comment blocks and populate them into @blocks.
|
87
|
+
# Parse the file or string for comment blocks and populate them into @blocks.
|
85
88
|
#
|
86
|
-
# Returns an Array
|
89
|
+
# Returns an Array of parsed comment Strings.
|
87
90
|
def parse_blocks
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
91
|
+
if !@file_path.nil?
|
92
|
+
# the input is an existing file
|
93
|
+
File.open @file_path do |file|
|
94
|
+
parse_blocks_input(file)
|
95
|
+
end
|
96
|
+
else
|
97
|
+
# @file_path is nil, we then expect the input to be a String
|
98
|
+
parse_blocks_input(@string_input)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def parse_blocks_input(input)
|
103
|
+
current_block = nil
|
104
|
+
inside_single_line_block = false
|
105
|
+
inside_multi_line_block = false
|
106
|
+
|
107
|
+
input.each_line do |line|
|
108
|
+
# Parse single-line style
|
109
|
+
if self.class.single_line_comment?(line)
|
110
|
+
parsed = self.class.parse_single_line line
|
111
|
+
if inside_single_line_block
|
112
|
+
current_block += "\n#{parsed}"
|
113
|
+
else
|
114
|
+
current_block = parsed.to_s
|
115
|
+
inside_single_line_block = true
|
103
116
|
end
|
117
|
+
end
|
104
118
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
end
|
119
|
+
# Parse multi-lines tyle
|
120
|
+
if self.class.start_multi_line_comment?(line) || inside_multi_line_block
|
121
|
+
parsed = self.class.parse_multi_line line
|
122
|
+
if inside_multi_line_block
|
123
|
+
current_block += "\n#{parsed}"
|
124
|
+
else
|
125
|
+
current_block = parsed
|
126
|
+
inside_multi_line_block = true
|
114
127
|
end
|
128
|
+
end
|
115
129
|
|
116
|
-
|
117
|
-
|
130
|
+
# End a multi-line block if detected
|
131
|
+
inside_multi_line_block = false if self.class.end_multi_line_comment?(line)
|
118
132
|
|
119
|
-
|
120
|
-
|
121
|
-
|
133
|
+
# Store the current block if we're done
|
134
|
+
unless self.class.single_line_comment?(line) || inside_multi_line_block
|
135
|
+
@blocks << normalize(current_block) unless current_block.nil?
|
122
136
|
|
123
|
-
|
124
|
-
|
125
|
-
end
|
137
|
+
inside_single_line_block = false
|
138
|
+
current_block = nil
|
126
139
|
end
|
127
140
|
end
|
128
|
-
|
129
141
|
@parsed = true
|
130
142
|
@blocks
|
131
143
|
end
|
@@ -161,4 +173,4 @@ module Kss
|
|
161
173
|
end
|
162
174
|
|
163
175
|
end
|
164
|
-
end
|
176
|
+
end
|
data/lib/kss/parser.rb
CHANGED
@@ -2,29 +2,41 @@ module Kss
|
|
2
2
|
# Public: The main KSS parser. Takes a directory full of SASS / SCSS / CSS
|
3
3
|
# files and parses the KSS within them.
|
4
4
|
class Parser
|
5
|
-
|
5
|
+
STYLEGUIDE_PATTERN = (/(?<!No )Styleguide [[:alnum:]]/i).freeze
|
6
|
+
|
6
7
|
# Public: Returns a hash of Sections.
|
7
8
|
attr_accessor :sections
|
8
|
-
|
9
|
-
# Public: Initializes a new parser based on a directory of files.
|
10
|
-
# within the directory recursively for any comment blocks
|
11
|
-
# KSS.
|
9
|
+
|
10
|
+
# Public: Initializes a new parser based on a directory of files or kss strings.
|
11
|
+
# Scans within the directory recursively or the strings for any comment blocks
|
12
|
+
# that look like KSS.
|
12
13
|
#
|
13
|
-
#
|
14
|
-
def initialize(*
|
14
|
+
# paths_or_strings - Each path String where style files are located, or each String containing KSS.
|
15
|
+
def initialize(*paths_or_strings)
|
15
16
|
@sections = {}
|
16
17
|
|
17
|
-
|
18
|
-
Dir
|
19
|
-
|
18
|
+
paths_or_strings.each do |path_or_string|
|
19
|
+
if Dir.exists?(path_or_string)
|
20
|
+
# argument is a path
|
21
|
+
path = path_or_string
|
22
|
+
Dir["#{path}/**/*.{css,less,sass,scss}"].each do |filename|
|
23
|
+
parser = CommentParser.new(filename)
|
24
|
+
parser.blocks.each do |comment_block|
|
25
|
+
add_section comment_block, filename if self.class.kss_block?(comment_block)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
else
|
29
|
+
# argument is a KSS string
|
30
|
+
kss_string = path_or_string
|
31
|
+
parser = CommentParser.new(kss_string)
|
20
32
|
parser.blocks.each do |comment_block|
|
21
|
-
add_section comment_block
|
33
|
+
add_section comment_block if self.class.kss_block?(comment_block)
|
22
34
|
end
|
23
35
|
end
|
24
36
|
end
|
25
37
|
end
|
26
38
|
|
27
|
-
def add_section comment_text, filename
|
39
|
+
def add_section comment_text, filename = ''
|
28
40
|
base_name = File.basename(filename)
|
29
41
|
section = Section.new(comment_text, base_name)
|
30
42
|
@sections[section.section] = section
|
@@ -38,7 +50,7 @@ module Kss
|
|
38
50
|
return false unless cleaned_comment.is_a? String
|
39
51
|
|
40
52
|
possible_reference = cleaned_comment.split("\n\n").last
|
41
|
-
possible_reference =~
|
53
|
+
possible_reference =~ STYLEGUIDE_PATTERN
|
42
54
|
end
|
43
55
|
|
44
56
|
# Public: Finds the Section for a given styleguide reference.
|
data/lib/kss/section.rb
CHANGED
@@ -35,7 +35,7 @@ module Kss
|
|
35
35
|
return @section unless @section.nil?
|
36
36
|
|
37
37
|
cleaned = section_comment.strip.sub(/\.$/, '') # Kill trailing period
|
38
|
-
@section = cleaned.match(/Styleguide (.+)/)[1]
|
38
|
+
@section = cleaned.match(/Styleguide (.+)/i)[1]
|
39
39
|
|
40
40
|
@section
|
41
41
|
end
|
@@ -77,13 +77,13 @@ module Kss
|
|
77
77
|
end
|
78
78
|
|
79
79
|
private
|
80
|
-
|
80
|
+
|
81
81
|
def section_comment
|
82
82
|
comment_sections.find do |text|
|
83
|
-
text =~
|
83
|
+
text =~ Parser::STYLEGUIDE_PATTERN
|
84
84
|
end.to_s
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
def modifiers_comment
|
88
88
|
comment_sections[1..-1].reject do |section|
|
89
89
|
section == section_comment
|
data/lib/kss/version.rb
CHANGED
@@ -36,3 +36,34 @@ a.button.star {
|
|
36
36
|
color: #ae7e00; }
|
37
37
|
a.button.star.disabled {
|
38
38
|
opacity: 0.5; }
|
39
|
+
|
40
|
+
/*
|
41
|
+
A big button
|
42
|
+
|
43
|
+
.really-big - Even bigger button
|
44
|
+
|
45
|
+
Styleguide Buttons.Big.
|
46
|
+
*/
|
47
|
+
a.button.big {
|
48
|
+
display: inline-block;
|
49
|
+
font-size: 10em; }
|
50
|
+
a.button.big.really-big {
|
51
|
+
font-size: 20em; }
|
52
|
+
|
53
|
+
/*
|
54
|
+
A button truly lime in color
|
55
|
+
|
56
|
+
Styleguide Buttons - Truly Lime
|
57
|
+
*/
|
58
|
+
a.button.lime {
|
59
|
+
color: lime;
|
60
|
+
}
|
61
|
+
|
62
|
+
/*
|
63
|
+
A button truly lime in color
|
64
|
+
|
65
|
+
Seen in styleguide 10.2
|
66
|
+
*/
|
67
|
+
a.button.tricksy {
|
68
|
+
background: sparkles;
|
69
|
+
}
|
Binary file
|
@@ -48,4 +48,20 @@ a.button.star{
|
|
48
48
|
&.disabled{
|
49
49
|
opacity:0.5;
|
50
50
|
}
|
51
|
-
}
|
51
|
+
}
|
52
|
+
|
53
|
+
/*
|
54
|
+
A big button
|
55
|
+
|
56
|
+
.really-big - Even bigger button
|
57
|
+
|
58
|
+
Styleguide Buttons.Big.
|
59
|
+
*/
|
60
|
+
a.button.big {
|
61
|
+
display: inline-block;
|
62
|
+
font-size: 10em;
|
63
|
+
|
64
|
+
.really-big {
|
65
|
+
font-size: 20em;
|
66
|
+
}
|
67
|
+
}
|
@@ -38,3 +38,15 @@ a.button.star
|
|
38
38
|
|
39
39
|
&.disabled
|
40
40
|
opacity: 0.5
|
41
|
+
|
42
|
+
// A big button
|
43
|
+
//
|
44
|
+
// .really-big - A really big button
|
45
|
+
//
|
46
|
+
// Styleguide Buttons.Big.
|
47
|
+
a.button.big
|
48
|
+
display: inline-block;
|
49
|
+
font-size: 10em;
|
50
|
+
|
51
|
+
&.really-big
|
52
|
+
font-size: 20em;
|
@@ -44,4 +44,18 @@ a.button.star{
|
|
44
44
|
&.disabled{
|
45
45
|
opacity:0.5;
|
46
46
|
}
|
47
|
-
}
|
47
|
+
}
|
48
|
+
|
49
|
+
// A big button
|
50
|
+
//
|
51
|
+
// .really-big - Even bigger button
|
52
|
+
//
|
53
|
+
// Styleguide Buttons.Big.
|
54
|
+
a.button.big {
|
55
|
+
display: inline-block;
|
56
|
+
font-size: 10em;
|
57
|
+
|
58
|
+
&.really-big {
|
59
|
+
font-size: 20em;
|
60
|
+
}
|
61
|
+
}
|
data/test/helper.rb
CHANGED
data/test/parser_test.rb
CHANGED
@@ -8,57 +8,6 @@ class ParserTest < Kss::Test
|
|
8
8
|
@css_parsed = Kss::Parser.new('test/fixtures/css')
|
9
9
|
@less_parsed = Kss::Parser.new('test/fixtures/less')
|
10
10
|
@multiple_parsed = Kss::Parser.new('test/fixtures/scss', 'test/fixtures/less')
|
11
|
-
|
12
|
-
@css_comment = <<comment
|
13
|
-
/*
|
14
|
-
A button suitable for giving stars to someone.
|
15
|
-
|
16
|
-
.star-given - A highlight indicating you've already given a star.
|
17
|
-
.disabled - Dims the button to indicate it cannot be used.
|
18
|
-
|
19
|
-
Styleguide 2.2.1.
|
20
|
-
*/
|
21
|
-
comment
|
22
|
-
|
23
|
-
@starred_css_comment = <<comment
|
24
|
-
/* A button suitable for giving stars to someone.
|
25
|
-
*
|
26
|
-
* .star-given - A highlight indicating you've already given a star.
|
27
|
-
* .disabled - Dims the button to indicate it cannot be used.
|
28
|
-
*
|
29
|
-
* Styleguide 2.2.1. */
|
30
|
-
comment
|
31
|
-
|
32
|
-
@slashed_css_comment = <<comment
|
33
|
-
// A button suitable for giving stars to someone.
|
34
|
-
//
|
35
|
-
// .star-given - A highlight indicating you've already given a star.
|
36
|
-
// .disabled - Dims the button to indicate it cannot be used.
|
37
|
-
//
|
38
|
-
// Styleguide 2.2.1.
|
39
|
-
comment
|
40
|
-
|
41
|
-
@indented_css_comment = <<comment
|
42
|
-
/*
|
43
|
-
A button suitable for giving stars to someone.
|
44
|
-
|
45
|
-
.star-given - A highlight indicating you've already given a star.
|
46
|
-
.disabled - Dims the button to indicate it cannot be used.
|
47
|
-
|
48
|
-
Styleguide 2.2.1.
|
49
|
-
*/
|
50
|
-
comment
|
51
|
-
|
52
|
-
@cleaned_css_comment = <<comment
|
53
|
-
A button suitable for giving stars to someone.
|
54
|
-
|
55
|
-
.star-given - A highlight indicating you've already given a star.
|
56
|
-
.disabled - Dims the button to indicate it cannot be used.
|
57
|
-
|
58
|
-
Styleguide 2.2.1.
|
59
|
-
comment
|
60
|
-
@cleaned_css_comment.rstrip!
|
61
|
-
|
62
11
|
end
|
63
12
|
|
64
13
|
test "parses KSS comments in SCSS" do
|
@@ -66,11 +15,21 @@ comment
|
|
66
15
|
@scss_parsed.section('2.1.1').description
|
67
16
|
end
|
68
17
|
|
18
|
+
test "parses KSS keys that are words in SCSS" do
|
19
|
+
assert_equal 'A big button',
|
20
|
+
@scss_parsed.section('Buttons.Big').description
|
21
|
+
end
|
22
|
+
|
69
23
|
test "parsers KSS comments in LESS" do
|
70
24
|
assert_equal 'Your standard form button.',
|
71
25
|
@less_parsed.section('2.1.1').description
|
72
26
|
end
|
73
27
|
|
28
|
+
test "parses KSS keys that are words in LESS" do
|
29
|
+
assert_equal 'A big button',
|
30
|
+
@less_parsed.section('Buttons.Big').description
|
31
|
+
end
|
32
|
+
|
74
33
|
test "parses KSS multi-line comments in SASS (/* ... */)" do
|
75
34
|
assert_equal 'Your standard form button.',
|
76
35
|
@sass_parsed.section('2.1.1').description
|
@@ -81,11 +40,26 @@ comment
|
|
81
40
|
@sass_parsed.section('2.2.1').description
|
82
41
|
end
|
83
42
|
|
43
|
+
test "parses KSS keys that are words in in SASS" do
|
44
|
+
assert_equal 'A big button',
|
45
|
+
@sass_parsed.section('Buttons.Big').description
|
46
|
+
end
|
47
|
+
|
84
48
|
test "parses KSS comments in CSS" do
|
85
49
|
assert_equal 'Your standard form button.',
|
86
50
|
@css_parsed.section('2.1.1').description
|
87
51
|
end
|
88
52
|
|
53
|
+
test "parses KSS keys that are words in CSS" do
|
54
|
+
assert_equal 'A big button',
|
55
|
+
@css_parsed.section('Buttons.Big').description
|
56
|
+
end
|
57
|
+
|
58
|
+
test "parses KSS keys that word phases in CSS" do
|
59
|
+
assert_equal 'A button truly lime in color',
|
60
|
+
@css_parsed.section('Buttons - Truly Lime').description
|
61
|
+
end
|
62
|
+
|
89
63
|
test "parses nested SCSS documents" do
|
90
64
|
assert_equal "Your standard form element.", @scss_parsed.section('3.0.0').description
|
91
65
|
assert_equal "Your standard text input box.", @scss_parsed.section('3.0.1').description
|
@@ -102,11 +76,42 @@ comment
|
|
102
76
|
end
|
103
77
|
|
104
78
|
test "public sections returns hash of sections" do
|
105
|
-
assert_equal
|
79
|
+
assert_equal 5, @css_parsed.sections.count
|
106
80
|
end
|
107
81
|
|
108
82
|
test "parse multiple paths" do
|
109
|
-
assert_equal
|
83
|
+
assert_equal 7, @multiple_parsed.sections.count
|
84
|
+
end
|
85
|
+
|
86
|
+
test "parse from string" do
|
87
|
+
scss_input =<<-'EOS'
|
88
|
+
// Your standard form element.
|
89
|
+
//
|
90
|
+
// Styleguide 3.0.0
|
91
|
+
form {
|
92
|
+
|
93
|
+
// Your standard text input box.
|
94
|
+
//
|
95
|
+
// Styleguide 3.0.1
|
96
|
+
input[type="text"] {
|
97
|
+
border: 1px solid #ccc;
|
98
|
+
}
|
99
|
+
}
|
100
|
+
EOS
|
101
|
+
assert_equal "Your standard form element.", Kss::Parser.new(scss_input).section('3.0.0').description
|
102
|
+
assert_equal "Your standard text input box.", @sass_parsed.section('3.0.1').description
|
110
103
|
end
|
111
104
|
|
105
|
+
test "parse with no styleguide reference comment" do
|
106
|
+
scss_input =<<-'EOS'
|
107
|
+
// Nothing here
|
108
|
+
//
|
109
|
+
// No styleguide reference.
|
110
|
+
input[type="text"] {
|
111
|
+
border: 1px solid #ccc;
|
112
|
+
}
|
113
|
+
EOS
|
114
|
+
|
115
|
+
assert Kss::Parser.new(scss_input)
|
116
|
+
end
|
112
117
|
end
|
data/test/section_test.rb
CHANGED
@@ -39,4 +39,10 @@ comment
|
|
39
39
|
assert_equal '2.1.1', @section.section
|
40
40
|
end
|
41
41
|
|
42
|
+
test "parses word phrases as styleguide references" do
|
43
|
+
@comment_text.gsub!('2.1.1', 'Buttons - Truly Lime')
|
44
|
+
section = Kss::Section.new(@comment_text, 'example.css')
|
45
|
+
assert_equal 'Buttons - Truly Lime', @section.section
|
46
|
+
end
|
47
|
+
|
42
48
|
end
|
metadata
CHANGED
@@ -1,20 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.5.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Kyle Neath
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-09-22 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
|
-
description:
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
description: |2
|
14
|
+
Inspired by TomDoc, KSS attempts to provide a methodology for writing
|
15
|
+
maintainable, documented CSS within a team. Specifically, KSS is a CSS
|
16
|
+
structure, documentation specification, and styleguide format.
|
17
|
+
|
18
|
+
This is a ruby library for parsing KSS documented CSS and generating
|
19
|
+
styleguides.
|
18
20
|
email: kneath@gmail.com
|
19
21
|
executables: []
|
20
22
|
extensions: []
|
@@ -33,6 +35,7 @@ files:
|
|
33
35
|
- test/comment_parser_test.rb
|
34
36
|
- test/fixtures/comments.txt
|
35
37
|
- test/fixtures/css/buttons.css
|
38
|
+
- test/fixtures/css/images/example.png
|
36
39
|
- test/fixtures/less/_label.less
|
37
40
|
- test/fixtures/less/buttons.less
|
38
41
|
- test/fixtures/less/mixins.less
|
@@ -45,27 +48,28 @@ files:
|
|
45
48
|
- test/parser_test.rb
|
46
49
|
- test/section_test.rb
|
47
50
|
homepage: http://github.com/kneath/kss
|
48
|
-
licenses:
|
51
|
+
licenses:
|
52
|
+
- MIT
|
53
|
+
metadata: {}
|
49
54
|
post_install_message:
|
50
55
|
rdoc_options: []
|
51
56
|
require_paths:
|
52
57
|
- lib
|
53
58
|
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
-
none: false
|
55
59
|
requirements:
|
56
|
-
- -
|
60
|
+
- - '>='
|
57
61
|
- !ruby/object:Gem::Version
|
58
62
|
version: '0'
|
59
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
-
none: false
|
61
64
|
requirements:
|
62
|
-
- -
|
65
|
+
- - '>='
|
63
66
|
- !ruby/object:Gem::Version
|
64
67
|
version: '0'
|
65
68
|
requirements: []
|
66
69
|
rubyforge_project:
|
67
|
-
rubygems_version:
|
70
|
+
rubygems_version: 2.0.0
|
68
71
|
signing_key:
|
69
|
-
specification_version:
|
72
|
+
specification_version: 4
|
70
73
|
summary: A library for parsing KSS documented stylesheets and generating styleguides
|
71
74
|
test_files: []
|
75
|
+
has_rdoc: false
|