Permalink
Browse files

Move precompilers from bin/kss-node to lib/kss.js

Means precompiler masks will be included by default.
Fixed an tiny issue with processing string masks too :)
  • Loading branch information...
1 parent 4c9cacc commit 632c9fea3a68ea1500eb9c466d501300a2aaf46e @hughsk hughsk committed Dec 1, 2012
Showing with 131 additions and 8 deletions.
  1. +1 −1 bin/kss-node
  2. +8 −5 lib/kss.js
  3. +39 −0 test/fixtures-styles/style.sass
  4. +39 −0 test/fixtures-styles/style.styl
  5. +39 −0 test/fixtures-styles/style.stylus
  6. +5 −2 test/kss.js
View
@@ -1,7 +1,7 @@
#!/usr/bin/env node
var kss = require(__dirname + '/../lib/kss.js'),
- preCompiler = require(__dirname + '/../lib/precompiler.js')(),
+ preCompiler = kss.precompilers,
handlebars = require('handlebars'),
cleanCss = require('clean-css'),
optimist = require('optimist'),
View
@@ -4,6 +4,7 @@ var walk = require('./walk.js'),
KssSection = require('./kss_section.js'),
KssStyleguide = require('./kss_styleguide.js'),
KssModifier = require('./kss_modifier.js'),
+ precompilers = require('./precompiler')(),
path = require('path'),
fs = require('fs'),
util = require('util'),
@@ -13,7 +14,7 @@ var walk = require('./walk.js'),
isDeprecated, isExperimental, hasPrefix,
commentExpressions = {
single: /\s*?\/\/(.*?)$/g,
- multiStart: /\/\*(.*?)$/,
+ multiStart: /\/\*\!?(.*?)$/,
multiFinish: /\*\//,
multiBeforeFinish: /(.*?)\*\//
};
@@ -37,14 +38,15 @@ traverse = function(directory, options, callback) {
throw new Error('No callback supplied for KSS.traverse!');
}
+ // Mask to search for particular file types - defaults to precompiler masks,
+ // or CSS and LESS only.
+ options.mask = options.mask || precompilers.mask || /\.css|\.less/;
- // Mask to search for particular file types - defaults to CSS and LESS only.
- options.mask = options.mask || /\.css|\.less/;
// If the mask is a string, convert it into a RegExp
if (!(options.mask instanceof RegExp)) {
options.mask = new RegExp(
- options.mask.replace(/\*/g, '.*')
+ '(?:' + options.mask.replace(/\*/g, '.*') + ')$'
);
}
@@ -477,5 +479,6 @@ module.exports = {
traverse: traverse,
KssStyleguide: KssStyleguide,
KssSection: KssSection,
- KssModifier: KssModifier
+ KssModifier: KssModifier,
+ precompilers: precompilers
};
@@ -0,0 +1,39 @@
+// A button suitable for giving stars to someone.
+//
+// Testing indentation for Markdown code.
+//
+// :hover - Subtle hover highlight.
+// .stars-given - A highlight indicating you've already given a star.
+// .stars-given:hover - Subtle hover highlight on top of stars-given styling.
+// .disabled - Dims the button to indicate it cannot be used.
+//
+// Styleguide 2.1.3.
+a.button.star{
+ background:#ddd;
+
+ &.star-given{
+
+ }
+ &.disabled{
+ ...
+ }
+}
+
+// A button suitable for giving stars to someone.
+//
+// :hover - Subtle hover highlight.
+// .stars-given - A highlight indicating you've already given a star.
+// .stars-given:hover - Subtle hover highlight on top of stars-given styling.
+// .disabled - Dims the button to indicate it cannot be used.
+//
+// Styleguide 2.1.4.
+a.button.star{
+ background:#ddd;
+
+ &.star-given{
+
+ }
+ &.disabled{
+ ...
+ }
+}
@@ -0,0 +1,39 @@
+// A button suitable for giving stars to someone.
+//
+// Testing indentation for Markdown code.
+//
+// :hover - Subtle hover highlight.
+// .stars-given - A highlight indicating you've already given a star.
+// .stars-given:hover - Subtle hover highlight on top of stars-given styling.
+// .disabled - Dims the button to indicate it cannot be used.
+//
+// Styleguide 2.1.3.
+a.button.star{
+ background:#ddd;
+
+ &.star-given{
+
+ }
+ &.disabled{
+ ...
+ }
+}
+
+// A button suitable for giving stars to someone.
+//
+// :hover - Subtle hover highlight.
+// .stars-given - A highlight indicating you've already given a star.
+// .stars-given:hover - Subtle hover highlight on top of stars-given styling.
+// .disabled - Dims the button to indicate it cannot be used.
+//
+// Styleguide 2.1.4.
+a.button.star{
+ background:#ddd;
+
+ &.star-given{
+
+ }
+ &.disabled{
+ ...
+ }
+}
@@ -0,0 +1,39 @@
+// A button suitable for giving stars to someone.
+//
+// Testing indentation for Markdown code.
+//
+// :hover - Subtle hover highlight.
+// .stars-given - A highlight indicating you've already given a star.
+// .stars-given:hover - Subtle hover highlight on top of stars-given styling.
+// .disabled - Dims the button to indicate it cannot be used.
+//
+// Styleguide 2.1.3.
+a.button.star{
+ background:#ddd;
+
+ &.star-given{
+
+ }
+ &.disabled{
+ ...
+ }
+}
+
+// A button suitable for giving stars to someone.
+//
+// :hover - Subtle hover highlight.
+// .stars-given - A highlight indicating you've already given a star.
+// .stars-given:hover - Subtle hover highlight on top of stars-given styling.
+// .disabled - Dims the button to indicate it cannot be used.
+//
+// Styleguide 2.1.4.
+a.button.star{
+ background:#ddd;
+
+ &.star-given{
+
+ }
+ &.disabled{
+ ...
+ }
+}
View
@@ -277,7 +277,7 @@ suite('#traverse', function() {
}, 'Only works when included at the beginning of a paragraph/header', { multiline: true});
});
suite('.experimental', function() {
-
+
common.testSection('Experimental: Spacing above and below', 'sections-status.less', function(section) {
assert.ok(section.data.experimental);
}, 'Still works with vertical line space', { multiline: true});
@@ -341,6 +341,9 @@ suite('#traverse', function() {
suite('Default', function() {
common.shouldFindFile('style.css', {}, true);
common.shouldFindFile('style.less', {}, true);
+ common.shouldFindFile('style.stylus', {}, true);
+ common.shouldFindFile('style.styl', {}, true);
+ common.shouldFindFile('style.sass', {}, true);
common.shouldFindFile('includes/buttons.less', {}, true);
common.shouldFindFile('includes/buttons.js', {}, false);
});
@@ -426,7 +429,7 @@ suite('#traverse', function() {
assert.equal(section.data.header, 'Misspelt Styleguide 4');
}, 'Style guide', { typos: true });
});
-
+
suite('Experimental', function() {
common.testSection('Experimental: In Header', 'sections-status.less', function(section) {
assert.ok(section.data.experimental);

0 comments on commit 632c9fe

Please sign in to comment.