Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
Document the Node.js API and the options it accepts.

Addresses Issue BlessCSS#35 and Issue BlessCSS#8
  • Loading branch information
AaronAsAChimp committed Aug 19, 2014
1 parent 5384e4c commit 2771f36
Showing 1 changed file with 129 additions and 4 deletions.
133 changes: 129 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,139 @@ progress on the new version.
bless.js [![Stories in Ready](https://badge.waffle.io/paulyoung/bless.js.png)](http://waffle.io/paulyoung/bless.js)
=======

Bless.js prepares files so that they are suitable for older versions of
Internet Explorer.

<http://blesscss.com>

about
-----
Build Tools
-----------

In addition to the `blessc` command line tool. There are third-party
integrations for existing build tools.

### Grunt with 'grunt-bless' ###

Integrate Bless.js in to your Grunt builds with the [grunt-bless](https://github.com/Ponginae/grunt-bless)
plugin.

### Gulp with 'gulp-bless' ###

[gulp-bless](https://github.com/adam-lynch/gulp-bless) integrates Bless.js into your Gulp builds.

Node.js API
-----------

Bless.js exposes an API that can be used to integrate into custom build tools.

### Parser(options) ###

When creating a new `Parser` object you must pass it an object containing the
output filename and the desired options (see below).

The parser object is linked to a specific output location passed to the
constructor. It is recommended to create a new instance of the parser for each
output file rather that reusing it.

```javascript
var Parser = requre('bless').Parser,
parser = new Parser({
'output': 'myfile.css',
'options': {}
});
```

#### parser.parse(css_str, callback) ####

Parses the contents of `css_str` and executes `callback`.

```javascript
parser.parse('#an-element { color: red }', function (err, files, numSelectors) {
// do something with `files` here.
console.log(files);
});
```

The callback should accept three parameters, `err`, `files`, `numSelectors`. The
`err` parameter contains information regarding any error that occurred during
parsing or `null` if there was no error.

The `files` parameter contains an array of objects that contains the file and
where it should be written to. The above example will output something
similar to.

```javascript
[
{
'filename': 'myfile.css',
'content': '#an-element { color: red }'
}
]
```

The `numSelectors` parameter contains a integer total of the number of selectors
found in the parsed CSS.

#### Parser.cleanup(options, output, callback) ####

A static method that will enumerate any files generated by bless. This is
helpful for cleaning up any files from previous runs of the parser.

```javascript
Parser.cleanup({}, 'myfile.css', function (err, files) {
// do something with `files` here.
console.log(files);
})
```

The `options` and `output` parameters should be the options passed to the
`Parser` object that generated the files. The `callback` parameter should be a
function that accepts two parameters `err` and `files`.

The `err` parameter will contain any error that occurred while attempting to
enumerate the files or `null` if no error occurred. The `files` parameter is the
list of filenames that were generated.

### Options ####

#### options.compress (-x, --compress) ####

Type: `Boolean`
Default value: `false`

Compress the css output added by bless. This _does not_ compress the CSS you
wrote. For that you should use a CSS minifier.

#### options.cleanup (--no-cleanup) ####

Type: `Boolean`
Default value: `true`

Clean up files generated by bless before proceeding.

#### options.force (-f, --force) ####

Type: `Boolean`
Default value: `false`

This will allow bless to overwrite the input file.

#### options.imports (--no-imports) ####

Type: `Boolean`
Default value: `true`
Added: v3.0.3

Enable or disable the use of `@import` in generated CSS files.

#### options.cacheBuster (--no-cache-buster) ####

Type: `Boolean`
Default value: `true`

For more information, visit <http://blesscss.com>.
Add or remove a cache-buster parameter from the generated CSS files.

license
License
-------

See `LICENSE` file.
Expand Down

0 comments on commit 2771f36

Please sign in to comment.