dss-parser-variable NPM version Dependency Status Build Status

A @variable parser for documenting SCSS/LESS variables from Documented Style Sheets (DSS).

Usage

In a file test.scss:

/**
 * @name Colours
 * @variable white
 * @variable blue - Sky blue
 * @variable dark-red Button outlines
 */
$blue: #0000FF;
$dark-red: #FF0000;
$black: #000000;

In 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:

{
    "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.