Module: kss

The core kss API can be imported with:

var kss = require('kss');

The various constructors and methods can then be accessed with:

var kssStyleguide = new kss.KssStyleguide();
var kssSection    = new kss.KssSection();
var kssModifier   = new kss.KssModifier();
var kssParameter  = new kss.KssParameter();
kss.parse();
kss.traverse();
Source:

Classes

KssModifier
KssParameter
KssSection
KssStyleguide

Methods

(static) parse(input, options, callback)

Parse an array/string of documented CSS, or an object of files and their content.

File object formatted as { "absolute filename": content, ... }.

This is called automatically as part of traverse but is publicly accessible as well.

Parameters:
Name Type Description
input Mixed

The input to parse

options Object

Options to alter the output content. Same as the options in traverse().

callback function

Called when parsing is complete

Source:

(static) traverse(directory, options, callback)

Traverse a directory, parse its contents, and create a KssStyleguide.

Callbacks receive an instance of KssStyleguide.

If you want to parse anything other than css, less, sass, or stylus files then you'll want to use options.mask to target a different set of file extensions.

kss.traverse('./stylesheets', { mask: '*.css' }, function(err, styleguide) {
    if (err) throw err;

    styleguide.section('2.1.1') // <KssSection>
});

There a few extra options you can pass to kss.traverse which will effect the output generated:

  • mask: Use a regex or string (e.g. *.less|*.css) to only parse files matching this value. Defaults to: *.css|*.less|*.sass|*.scss|*.styl|*.stylus
  • markdown: kss-node supports built-in Markdown formatting of its documentation, thanks to marked. It's enabled by default, but you can disable it by adding markdown: false to the options object.
  • multiline: kss-node makes the header available separately from the description. To make kss-node behave like the Ruby KSS, disable this option and the title will remain a part of the description. This setting is enabled by default, but you can disable it by adding multiline: false to your options.
  • typos: Thanks to natural, kss-node can parse keywords phonetically rather then by their string value. In short: make a typo and the library will do its best to read it anyway. Enabled by default.
Parameters:
Name Type Description
directory String | Array

The directory(s) to traverse

options Object

Options to alter the output content (optional)

callback function

Called when traversal AND parsing is complete

Source: