Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix basic plain CSS support, fixes #507 #523

Merged
merged 2 commits into from
Mar 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/modules/variable-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function parseVariableDeclarations(string, syntax) {
}),
visitors = {
sass: {
// Visitor for SASS and SCSS syntaxes
// Visitor for SASS, SCSS and plain CSS syntaxes
test: function(name, nodes) {
return name === 'declaration' && nodes[1][0] === 'variable';
},
Expand Down Expand Up @@ -67,6 +67,7 @@ function parseVariableDeclarations(string, syntax) {
},
visitor;

visitors.css = visitors.sass;
visitors.scss = visitors.sass;
visitor = visitors[syntax];

Expand All @@ -86,7 +87,7 @@ function findVariables(string, syntax) {
}),
visitors = {
sass: {
// Visitor for SASS and SCSS syntaxes
// Visitor for SASS, SCSS and plain CSS syntaxes
test: function(name, nodes) {
return (name === 'declaration' && nodes[1][0] === 'variable') || (name === 'variable' && nodes[0] === 'ident');
},
Expand All @@ -101,6 +102,7 @@ function findVariables(string, syntax) {

// For this task LESS visitor is identical to SASS
visitors.less = visitors.sass;
visitors.css = visitors.sass;
visitors.scss = visitors.sass;
visitor = visitors[syntax];

Expand Down
18 changes: 18 additions & 0 deletions test/integration/npm-package.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ describe('style guide generated with npm package executable', function() {
addJsonAssertions(output, variablesFile);
});

describe('from plain CSS test project', function() {
var output = path.join(testDir, 'css-test-output');

before(function(done) {
this.timeout(30000);
generateCssTestProjectStyleGuide(output).then(done).catch(done);
});

checkCommonStructure(output);
});

describe('from internal client files', function() {
var output = path.join(testDir, 'demo-test-output');
before(function(done) {
Expand Down Expand Up @@ -109,6 +120,13 @@ function generateLessTestProjectStyleGuide(output, variablesFile) {
return generateStyleGuide(args);
}

function generateCssTestProjectStyleGuide(output) {
var args = getSharedConfig();
args.kssSource = path.resolve(currentDir, '../projects/css-project/source/**/*.css');
args.output = output;
return generateStyleGuide(args);
}

function generateDemoStyleGuide(output) {
var args = getSharedConfig();
args.kssSource = path.resolve(npmSgDir, 'lib/app/**/*.scss');
Expand Down
1 change: 1 addition & 0 deletions test/projects/css-project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
output/
7 changes: 7 additions & 0 deletions test/projects/css-project/source/styleguide_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extraHead": [
"<!-- extraHead comment -->"
],
"overviewPath": "test_overview.md",
"commonClass": ["custom-class-1", "custom-class-2"],
}
62 changes: 62 additions & 0 deletions test/projects/css-project/source/styles/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

/*
First section

Markup:
<div class="section">Section markup</div>

Styleguide 1.0
*/

.section {
color: #ff0000;
}
.section:hover {
color: #00ff00;
}
.section:active {
color: #0000ff;
}

/*
Section with modifiers

#ff0000 - Red test color
#00ff00 - Green test color
#0000ff - Blue test color
.other-modifier - Other modifier

Markup:
<div style="background: {$modifiers};"></div>

Styleguide 2.0
*/

/*
Section without markup

Styleguide 3.0
*/

.test-css {color: purple;}

/*
Section with multiple variables

Markup:
<div class="section">Section markup</div>

Styleguide 4.0
*/

.section1 {
color: #ff0000;
}

.section2 {
background-color: #00ff00;
}

.section3 {
border: 1px solid #0000ff;
}
13 changes: 13 additions & 0 deletions test/projects/css-project/source/test_overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Title1

Ut turkish, wings, sit to go barista half and half medium roast. Viennese sit, java, id trifecta doppio wings white ristretto coffee aged. Est con panna single shot, organic percolator that americano, bar single origin viennese black arabica. Espresso et a variety macchiato saucer skinny. Breve, froth, flavour grounds instant ut body sugar coffee.

<div class="foobar>Test code snippet</div>

## Title2

To go espresso organic bar extraction galão filter. Flavour barista mazagran mocha robusta, iced lungo coffee barista affogato. Con panna, sit aromatic so that frappuccino beans. Filter ut acerbic lungo java caramelization kopi-luwak a filter. Latte eu dripper, bar milk, body latte affogato aged froth.

### Title3

[Example link](http://example.com)