Skip to content

Commit e485ba5

Browse files
committed
Merge pull request reworkcss#25 from andreypopp/master
Add docs
2 parents 9e2e590 + 611c1c9 commit e485ba5

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

History.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
1.4.0 / 2013-XX-XX
2+
==================
3+
4+
* add source map generation
15

26
1.3.2 / 2013-10-18
37
==================

Readme.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,32 @@
22

33
CSS compiler using the AST provided by [css-parse](https://github.com/visionmedia/css-parse).
44

5+
## Usage
6+
7+
`css-stringify` exports a single function which dumps CSS AST:
8+
9+
var stringify = require('css-stringify');
10+
var parse = require('css-parse');
11+
12+
var ast = parse('body { font-size: 12px; }');
13+
14+
var str = stringify(ast);
15+
16+
To get compressed output pass `compress` option:
17+
18+
var compressed = stringify(ast, {compress: true});
19+
20+
To get a source map pass `sourcemap` option:
21+
22+
var ast = parse('body { font-size: 12px; }', {position: true});
23+
var result = stringify(ast, {sourcemap: true});
24+
25+
result.code // string with CSS
26+
result.map // source map
27+
28+
Note that the AST should contain position information (`position` option of
29+
`css-parse` set to `true`).
30+
531
## Performance
632

733
Formats 15,000 lines of CSS (2mb) in 23ms on my macbook air.

index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ var Identity = require('./lib/identity');
1111
*
1212
* @param {Object} node
1313
* @param {Object} [options]
14+
* @param {Boolean} [options.sourcemap] generate source map,
15+
* if set to true this will change return value to
16+
* `{code: '...', map: {...}}`, `node` argument should contain
17+
* position information (e.g. parsed by css-parse with
18+
* `position` option set to `true`)
19+
* @param {Boolean} [options.compress] compress output (ignores indent option)
20+
* @param {String} [options.indent] a string used for indents (defaults to 2 spaces)
21+
*
1422
* @return {String}
1523
* @api public
1624
*/

0 commit comments

Comments
 (0)