Module: kss/lib/parse

The kss/lib/parse module is normally accessed via the parse() method of the kss module:

var kss = require('kss');
kss.parse(input, options, callback);
Source:

Methods

(private, inner) checkReference(paragraphs, options) → {Boolean|String}

Check a section for the reference number it may or may not have.

Parameters:
Name Type Description
paragraphs Array

An array of the paragraphs in a single block.

options Object

The options object passed on from the initial functions

Source:
Returns:

False if not found, otherwise returns the reference number as a string.

Type
Boolean | String

(private, inner) createModifiers(lines, options) → {Array}

Takes an array of modifier lines, and turns it into instances of KssModifier.

Parameters:
Name Type Description
lines Array

Modifier lines, which should all be strings.

options Object

Any options passed on by the functions above.

Source:
Returns:

The modifier instances created.

Type
Array

(private, inner) createParameters(lines, options) → {Array}

Takes an array of parameter lines, and turns it into instances of KssParameter.

Parameters:
Name Type Description
lines Array

Parameter lines, which should all be strings.

options Object

Any options passed on by the functions above.

Source:
Returns:

The parameter instances created.

Type
Array

(private, inner) findBlocks(input, options) → {Array}

Returns an array of comment blocks found within a string.

Parameters:
Name Type Description
input String

The string to search.

options Object

Optional parameters to pass. Inherited from parse.

Source:
Returns:

The blocks found.

Type
Array

(private, inner) hasPrefix(description, options, prefix) → {Boolean}

Essentially this function checks if a string is prefixed by a particular attribute, e.g. 'Deprecated:' and 'Markup:'

If options.typos is enabled it'll try check if the first word at least sounds like the word we're checking for.

Parameters:
Name Type Description
description String

The string to check

options Object

The options passed on from previous functions

prefix String

The prefix to search for

Source:
Returns:

Whether the description contains the specified prefix.

Type
Boolean

(private, inner) isDeprecated(description, options) → {Boolean}

Check if the description indicates that a section is deprecated.

Parameters:
Name Type Description
description String

The description of that section

options Object

The options passed on from previous functions

Source:
Returns:

Whether the description indicates the section is deprecated.

Type
Boolean

(private, inner) isExperimental(description, options) → {Boolean}

Check if the description indicates that a section is experimental.

Parameters:
Name Type Description
description String

The description of that section

options Object

The options passed on from previous functions

Source:
Returns:

Whether the description indicates the section is experimental.

Type
Boolean

(private, inner) parseChunk(data, input, options) → {Object}

Take a chunk of text and parse the comments. This is the primary parsing function, and eventually returns a data variable to use to create a new instance of KssStyleguide.

Parameters:
Name Type Description
data Object

JSON object containing all of the style guide data.

input String

Text to be parsed, i.e. a single CSS/LESS/etc. file's content.

options Object

The options passed on from traverse or parse

Source:
Returns:

The raw style guide data from the newly parsed text.

Type
Object

(private, inner) processProperty(propertyName, paragraphs, options, sectionData, processValue) → {Object}

Checks if there is a specific property in the comment block and removes it from the original array.

Parameters:
Name Type Description
propertyName String

The name of the property to search for

paragraphs Array

An array of the paragraphs in a single block

options Object

The options object passed on from the initial functions

sectionData Object

The original data object of a section.

processValue function

A function to massage the value before it is inserted into the sectionData.

Source:
Returns:

A new data object for the section.

Type
Object