dss-parser-variable
Version:
A variable parser for DSS (Documented Stylesheets)
70 lines (50 loc) • 1.95 kB
Markdown
dss-parser-variable [![NPM version][npm-image]][npm-url] [![Dependency Status][depstat-image]][depstat-url] [![Build Status][travis-image]][travis-url]
===
A `@variable` parser for documenting SCSS/LESS variables from [Documented Style Sheets][] (DSS).
In a file `test.scss`:
```css
/**
* @name Colours
* @variable white
* @variable blue - Sky blue
* @variable dark-red Button outlines
*/
$blue:
$dark-red:
$black:
```
In JavaScript:
```javascript
var fs = require('fs'),
dss = require('dss'),
variableParser = require('dss-parser-variable');
dss.parser('variable', variableParser());
var scss = fs.readFileSync('test.scss'),
options = {},
callback = function(parsed){
console.log(JSON.stringify(parsed, true, 4));
};
dss.parse(scss, options, callback);
```
Will output:
```json
{
"blocks": [{
"name": "Colours",
"variable": [
{ "name": "blue", "description": "Sky blue", "value": "#0000FF" },
{ "name": "dark-red", "description": "Button outlines", "value": "#FF0000" }
]
}]
}
```
Note there is no entry for `white` because the variable does not exist in the file, and there is no entry for `black` because there is no description in the DSS block.
If you pass `false` flag to the constructor it will include variables that does not exist in the file, i.e. there would be entry for a `white` in output.
[]:https://github.com/darcyclarke/DSS
[]: https://npmjs.org/package/dss-parser-variable
[]: http://img.shields.io/npm/v/dss-parser-variable.svg?style=flat
[]: https://david-dm.org/paulwib/dss-parser-variable
[]: https://david-dm.org/paulwib/dss-parser-variable.svg?style=flat
[]: http://img.shields.io/travis/paulwib/dss-parser-variable/master.svg?style=flat
[]: https://travis-ci.org/paulwib/dss-parser-variable