Skip to content

Commit 45505d7

Browse files
committed
Merge pull request #203 from jpbackman/remove-dev-instructions-from-readme
Move development instructions to own file, add TOC to readme
2 parents 670ded7 + 5ef5e8c commit 45505d7

File tree

5 files changed

+139
-57
lines changed

5 files changed

+139
-57
lines changed

DEVELOPMENT.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Development instructions
2+
3+
### Running development server and watches
4+
5+
The project contains a small demo stylesheet that can be used to develop the UI.
6+
Start watching UI code changes in lib/app and build the app using the demo stylesheets:
7+
8+
gulp dev
9+
10+
Running the task also runs a small development server, and does the same as:
11+
12+
gulp watch --source ./lib/app --output ./demo-output --config ./lib/app/styleguide_config.json
13+
14+
### Running tests
15+
16+
Run all the tests and JSCS linting with
17+
18+
npm test
19+
20+
Node module tests are ran with Mocha, UI related tests with Karma & PhantomJS.
21+
22+
### Coding convention
23+
24+
This project follows AirBNB-ish JavaScript coding convention (with a few changes). It is tuned to use [JSCS]() as a code
25+
checker. The checking is injected into the testing process, so you can see in Travis respond to your pull-request if your
26+
files follow the convention.
27+
28+
To be able to check during development, please
29+
30+
* run `$ gulp jscs`
31+
* use [JSCS editor plugins](https://github.com/jscs-dev/node-jscs#friendly-packages)
32+
* use [pre-commit hook](https://github.com/SC5/sc5-configurations/tree/master/.githooks/pre-commit)
33+
34+
## How to release
35+
36+
1. Check that all the needed pull requests are merged
37+
1. Make sure that your clone fetched all the tags which exist in the SC5 repo
38+
1. Rebase your `master` branch against SC5
39+
1. Create `release/x.y.z` branch with the number of upcoming version and switch to it
40+
1. Increment the package number in `package.json`
41+
1. Run `gulp publish`
42+
1. Check the `CHANGELOG.md` file. You can remove not needed items or rename them.
43+
1. Commit changes
44+
1. Make a pull request from your feature branch
45+
1. Once your pull request is merged, rebase your `master` against SC5 again
46+
1. Run `npm publish`
47+
1. Create a versioning tag in GitHub. Insert the `CHANGELOG.md` content as a description of this versioning tag.

README.md

Lines changed: 37 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,20 @@ Styleguide generator is a handy little tool that helps you generate good looking
55
styleguides from stylesheets using KSS notation. Styleguide generator can be
66
used via command line utility, gulp task or grunt task (needs grunt-gulp) with minimal effort.
77

8-
## How to use
8+
## Table of contents
9+
10+
* [Usage](#usage)
11+
* [As a command line tool](#as-a-command-line-tool)
12+
* [As a module in your project](#as-a-module-in-your-project)
13+
* [With Gulp](#with-gulp)
14+
* [With Grunt](#with-grunt)
15+
* [Build options](#build-options)
16+
* [Documenting syntax](#documenting-syntax)
17+
* [Wrapper markup](#wrapper-markup)
18+
* [Designer tool](#designer-tool)
19+
* [Demo](#demo)
20+
21+
## Usage
922

1023
You should familiarize yourself with both [KSS](https://github.com/kneath/kss)
1124
and [node-kss](https://github.com/kss-node/kss-node) to get yourself started.
@@ -16,11 +29,11 @@ SC5 Styleguide provides additions to KSS syntax which you can learn [below](#use
1629

1730
Styleline command line tool searches all *.css, *.scss and *.less files from source directory and generates stand-alone styleguide to output path. You can host styleguide files yourself with any HTTP server or start built-in web server.
1831

19-
To install as a global command line tool
32+
Installing as a global command line tool
2033

2134
npm install -g sc5-styleguide
2235

23-
How to use from command line
36+
Using from the command line
2437

2538
styleguide -s <source_path> -o <output_path> [-c <config_file>] [--server] [--watch]
2639

@@ -60,7 +73,7 @@ Config JSON file could contain following settings
6073
]
6174
}
6275

63-
For more specific documentation. See [Build Options](#build-options) section.
76+
For more specific documentation. See [Build options](#build-options) section.
6477

6578
### As a module in your project
6679

@@ -89,7 +102,7 @@ For more specific documentation. See [Build Options](#build-options) section.
89102
.pipe(gulp.dest("<destination path>"));
90103
});
91104

92-
For more specific documentation. See [Build Options](#build-options) section.
105+
For more specific documentation. See [Build options](#build-options) section.
93106

94107
### With Grunt
95108

@@ -129,7 +142,7 @@ Then you are able to use the same gulp task inside you `Gruntfile`:
129142

130143
For more specific documentation. See next section.
131144

132-
### Build Options
145+
### Build options
133146

134147
The gulp function and configuration JSON accepts identically named parameters
135148

@@ -200,7 +213,8 @@ Note: When using templateUrl in directives, the template path is relative to sty
200213

201214
Document your CSS components with [KSS](http://warpspire.com/kss/)
202215

203-
### Wrapper
216+
### Wrapper markup
217+
204218
Sometimes your component examples need a wrapper. For example:
205219
* you need to show how to use `<li>` element which works only with `<ul>` container;
206220
* your component is not visible with white background;
@@ -269,11 +283,22 @@ a KSS markup
269283
// Styleguide 1.1
270284
```
271285

272-
would produce `<div class="parent-wrapper"><div class="parent"></div></div>` for the Parent section and
273-
`<div class="parent-wrapper"><div class="parent"><span class="child"></span></div></div>` for the Child
274-
section.
286+
would produce a Parent section:
287+
```
288+
<div class="parent-wrapper">
289+
<div class="parent"></div>
290+
</div>
291+
```
292+
and a Child section:
293+
```
294+
<div class="parent-wrapper">
295+
<div class="parent">
296+
<span class="child"></span>
297+
</div>
298+
</div>
299+
```
275300

276-
## Desiger tools
301+
## Designer tool
277302

278303
When sassVariables is defined and styleguide is served with the built-in server, designer tool is also enabled. Designer tool is experimental feature that allow style variable editing in the browser and saving changed variables back to the source file.
279304

@@ -287,44 +312,4 @@ Note: If you installed styleguide by cloning repository directly instead of npm
287312

288313
The demo generates styleguide to `demo-output` directory.
289314

290-
## How to develop
291-
292-
Projects contains small demo stylesheet that can be used to develop the UI.
293-
Start watching UI changes in lib/app and build the app using the demo stylesheets:
294-
295-
gulp dev
296-
297-
Running the task also runs a small development server, and does the same as:
298-
299-
gulp watch --source ./lib/app --output ./demo-output --config ./lib/app/styleguide_config.json
300-
301-
### Running tests
302-
303-
npm test
304-
305-
### Coding convention
306-
307-
This project follows AirBNB-ish JavaScript coding convention (with a few changes). It is tuned to use [JSCS]() as a code
308-
checker. The checking is injected into the testing process, so you can see in Travis respond to your pull-request if your
309-
files follow the convention.
310-
311-
To be able to check during development, please
312-
313-
* run `$ gulp jscs`
314-
* use [JSCS editor plugins](https://github.com/jscs-dev/node-jscs#friendly-packages)
315-
* use [pre-commit hook](https://github.com/SC5/sc5-configurations/tree/master/.githooks/pre-commit)
316-
317-
## How to release
318-
319-
1. Check that all the needed pull requests are merged
320-
1. Make sure that your clone fetched all the tags which exist in the SC5 repo
321-
1. Rebase your `master` branch against SC5
322-
1. Create `feature/x.y.z` branch with the number of upcoming version and switch to it
323-
1. Increment the package number in `package.json`
324-
1. Run `gulp publish`
325-
1. Check the `CHANGELOG.md` file. You can remove not needed items or rename them.
326-
1. Commit changes
327-
1. Make a pull request from your feature branch
328-
1. Once your pull request is merged, rebase your `master` against SC5 again
329-
1. Run `npm publish`
330-
1. Create a versioning tag in GitHub. Insert the `CHANGELOG.md` content as a description of this versioning tag.
315+
Point your browser to <http://localhost:3000>

lib/app/sass/app.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ a.sg:active {
149149
}
150150

151151
p.sg {
152+
margin-top: 1.3em;
152153
margin-bottom: 1.3em;
153154
line-height: 1.5em;
154155
color: rgba(#333, 1);
@@ -165,6 +166,11 @@ li.sg {
165166
padding: 0.2em 0;
166167
}
167168

169+
.sg {
170+
strong {
171+
font-weight: 700;
172+
}
173+
}
168174
// Buttons
169175
//
170176
// Button styles used in the styleguide

lib/modules/markdown.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
'use strict';
22

33
var marked = require('gulp-marked'),
4-
vfs = require('vinyl-fs');
4+
vfs = require('vinyl-fs'),
5+
excludeLinks = [
6+
'https://travis-ci.org/SC5/sc5-styleguide',
7+
'https://david-dm.org/SC5/sc5-styleguide'
8+
];
9+
10+
function dasherize(str) {
11+
return str.replace(/\s/ig, '-').toLowerCase();
12+
}
513

614
module.exports = {
715

@@ -15,7 +23,7 @@ module.exports = {
1523
var renderer = {};
1624
// Define custom renderers for markup blocks
1725
renderer.heading = function(text, level) {
18-
return '<h' + level + ' class="sg">' + text + '</h' + level + '>';
26+
return '<a name=' + dasherize(text) + '></a><h' + level + ' class="sg">' + text + '</h' + level + '>';
1927
};
2028
renderer.paragraph = function(text) {
2129
return '<p class="sg">' + text + '</p>';
@@ -24,6 +32,10 @@ module.exports = {
2432
return '<li class="sg">' + text + '</li>\n';
2533
};
2634
renderer.link = function(href, title, text) {
35+
if (excludeLinks.indexOf(href) >= 0) {
36+
return '';
37+
}
38+
2739
if (this.options.sanitize) {
2840
try {
2941
var prot = decodeURIComponent(unescape(href))
@@ -51,7 +63,7 @@ module.exports = {
5163
.replace(/>/g, '&gt;')
5264
.replace(/"/g, '&quot;')
5365
.replace(/'/g, '&#39;');
54-
}
66+
};
5567

5668
if (this.options.highlight) {
5769
var out = this.options.highlight(code, lang);
@@ -73,8 +85,8 @@ module.exports = {
7385
+ '">'
7486
+ (escaped ? code : htmlEscape(code, true))
7587
+ '\n</code></pre>\n';
76-
}
88+
};
7789
return renderer;
7890
}
7991

80-
}
92+
};

test/markdown.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,38 @@ var gulp = require('gulp'),
66

77
describe('Markdown', function() {
88

9+
describe('renderer', function() {
10+
11+
var renderer, result;
12+
13+
beforeEach(function() {
14+
renderer = markdown.getRenderer();
15+
renderer.options = {
16+
sanitize: true
17+
};
18+
});
19+
20+
describe('link', function() {
21+
22+
it('adds class .sg to <a> tags', function() {
23+
result = renderer.link('linkHref', 'title', 'link text');
24+
expect(result).to.eql('<a class="sg" href="linkHref" title="title">link text</a>');
25+
});
26+
27+
it('excludes link to https://travis-ci.org/SC5/sc5-styleguide', function() {
28+
result = renderer.link('https://travis-ci.org/SC5/sc5-styleguide');
29+
expect(result).to.eql('');
30+
});
31+
32+
it('excludes link to https://david-dm.org/SC5/sc5-styleguide', function() {
33+
result = renderer.link('https://david-dm.org/SC5/sc5-styleguide');
34+
expect(result).to.eql('');
35+
});
36+
37+
});
38+
39+
});
40+
941
it('getRenderer if formed correctly', function() {
1042
var renderer = markdown.getRenderer();
1143
expect(renderer).to.be.an('object');

0 commit comments

Comments
 (0)