The kss/lib/parse
module is normally accessed via the
parse()
method of the kss
module:
const kss = require('kss');
let styleGuide = kss.parse(input, options);
- Source:
Methods
(private, inner) createModifiers(rawModifiers, options) → {Array}
Takes an array of modifier lines, and turns it into a JSON equivalent of KssModifier.
Parameters:
Name | Type | Description |
---|---|---|
rawModifiers |
Array | Raw Modifiers, which should all be strings. |
options |
Object | The options object. |
- Source:
Returns:
The modifier instances created.
- Type
- Array
(private, inner) createParameters(rawParameters, options) → {Array}
Takes an array of parameter lines, and turns it into instances of KssParameter.
Parameters:
Name | Type | Description |
---|---|---|
rawParameters |
Array | Raw parameters, which should all be strings. |
options |
Object | The options object. |
- Source:
Returns:
The parameter instances created.
- Type
- Array
(private, inner) findCommentBlocks(input) → {Array}
Returns an array of comment blocks found within a string.
Parameters:
Name | Type | Description |
---|---|---|
input |
String | The string to search. |
- Source:
Returns:
An array of blocks found as objects containing line, text, and raw properties.
- Type
- Array
(private, inner) findReference(text) → {Boolean|String}
Check a section for the reference number it may or may not have.
Parameters:
Name | Type | Description |
---|---|---|
text |
Array | An array of the paragraphs in a single block. |
- Source:
Returns:
False if not found, otherwise returns the reference number as a string.
- Type
- Boolean | String
(private, inner) hasPrefix(description, prefix) → {Boolean}
Essentially this function checks if a string is prefixed by a particular attribute, e.g. 'Deprecated:' and 'Markup:'
Parameters:
Name | Type | Description |
---|---|---|
description |
String | The string to check. |
prefix |
String | The prefix to search for. |
- Source:
Returns:
Whether the description contains the specified prefix.
- Type
- Boolean
(private, inner) parseColors(text) → {Array}
Convert colors doc block to a collection of color objects
Parameters:
Name | Type | Description |
---|---|---|
text |
String | paragraph from a comment block. |
- Source:
Returns:
collection of color objects {name: '…', color: '…'}
- Type
- Array
(private, inner) processProperty(paragraphs, propertyName, processValueopt)
Checks if there is a specific property in the comment block, adds it to
this
, and removes it from the original array of paragraphs.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
paragraphs |
Array | An array of the paragraphs in a single comment block. |
|
propertyName |
String | The name of the property to search for. |
|
processValue |
function |
<optional> |
A function to massage the value before it is
inserted into |
- Source:
(private, inner) toFloat(value) → {Float}
Convert String to Float
Parameters:
Name | Type | Description |
---|---|---|
value |
String | string of a number |
- Source:
Returns:
string converted
- Type
- Float