Skip to content

Commit facc12e

Browse files
committed
tweak docs a bit
1 parent e485ba5 commit facc12e

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

Readme.md

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,36 @@
22

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

5-
## Usage
5+
## API
66

7-
`css-stringify` exports a single function which dumps CSS AST:
7+
### stringify(object, [options])
88

9-
var stringify = require('css-stringify');
10-
var parse = require('css-parse');
9+
Accepts an AST `object` from css-parse and returns a CSS string.
1110

12-
var ast = parse('body { font-size: 12px; }');
11+
```js
12+
var stringify = require('css-stringify');
13+
var parse = require('css-parse');
1314

14-
var str = stringify(ast);
15+
var ast = parse('body { font-size: 12px; }');
16+
var css = stringify(ast);
17+
```
1518

16-
To get compressed output pass `compress` option:
19+
Optionally you may `compress` the output:
1720

18-
var compressed = stringify(ast, {compress: true});
21+
```js
22+
var css = stringify(ast, { compress: true });
23+
```
1924

20-
To get a source map pass `sourcemap` option:
25+
Or return a `sourcemap` along with the CSS output,
26+
which requires the use of the css-parse `position` option.
2127

22-
var ast = parse('body { font-size: 12px; }', {position: true});
23-
var result = stringify(ast, {sourcemap: true});
28+
```js
29+
var ast = parse('body { font-size: 12px; }', { position: true });
30+
var result = stringify(ast, { sourcemap: true });
2431

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`).
32+
result.code // string with CSS
33+
result.map // source map
34+
```
3035

3136
## Performance
3237

index.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,13 @@ var Identity = require('./lib/identity');
99
/**
1010
* Stringfy the given AST `node`.
1111
*
12+
* Options:
13+
*
14+
* - `compress` space-optimized output
15+
* - `sourcemap` return an object with `.code` and `.map`
16+
*
1217
* @param {Object} node
1318
* @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-
*
2219
* @return {String}
2320
* @api public
2421
*/

0 commit comments

Comments
 (0)