Constructor
new KssStyleGuide(dataopt)
Creates a KssStyleGuide object and stores the given data.
If passed an object, it will add autoInit
, customPropertyNames
, and
sections
properties.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
data |
Object |
<optional> |
An object of data. |
- Source:
Methods
autoInit(autoInit) → {KssStyleGuide}
Toggles the auto-initialization setting of this style guide.
If a false
value is provided, auto-initialization is disabled and users
will be required to call init()
manually after adding sections via
sections()
. If a true' value is provided, auto-initialization will be
enabled and the
init()` method will immediately be called.
Parameters:
Name | Type | Description |
---|---|---|
autoInit |
boolean | The new setting for auto-initialization. |
- Source:
Returns:
The KssStyleGuide
object is returned to allow
chaining of methods.
- Type
- KssStyleGuide
customPropertyNames(namesopt) → {KssStyleGuide|Array.<string>}
Gets or sets the list of custom properties of the style guide.
If the names
value is provided, the names are added to the style guide's
list of custom properties. Otherwise, the style guide's list of custom
properties is returned.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
names |
string | Array.<string> |
<optional> |
Optional. The names of of the section. |
- Source:
Returns:
If names
is given, the KssStyleGuide
object is returned to allow chaining of methods. Otherwise, the list of
custom properties of the style guide is returned.
- Type
- KssStyleGuide | Array.<string>
hasNumericReferences() → {boolean}
Returns whether the style guide has numeric references or not.
- Source:
Returns:
Whether the style guide has numeric references or not.
- Type
- boolean
init() → {KssStyleGuide}
Sorts the style guides sections and (re-)initializes some section values.
Some section data is dependent on the state of the KssStyleGuide. When
sections are added with sections()
, it determines what updates are needed.
If needed, this method:
- Calculates the depth of the reference for each section. e.g. Section 2.1.7 has a depth of 3.
- Sorts all the sections by reference.
- Calculates a reference number if the style guide uses word-based references.
By default this method is called automatically whenever new sections are added to the style guide. This
- Source:
Returns:
Returns the KssStyleGuide
object to allow chaining
of methods.
- Type
- KssStyleGuide
referenceDelimiter() → {string}
Returns the delimiter used in the style guide's section references.
- Source:
Returns:
The delimiter used in the section references.
- Type
- string
sections(sectionsopt) → {KssStyleGuide|KssSection|Array.<KssSection>|boolean}
Gets or sets the sections of the style guide.
If sections
objects are provided, the sections are added to the style
guide. Otherwise, a search is performed to return the desired sections.
There's a few ways to use search with this method:
sections()
returns all of the sections.
Using strings:
sections('2')
returns Section 2.sections('2.*')
returns Section 2 and all of its descendants.sections('2.x')
returns Section 2's children only.sections('2.x.x')
returns Section 2's children, and their children too.
Or Regular Expressions:
sections(/2\.[1-5]/)
returns Sections 2.1 through to 2.5.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
sections |
Object | Array.<Object> | string | RegExp |
<optional> |
Optional. A section object or array of secction objects to add to the style guide. Or a string or Regexp object to match a KssSection's style guide reference. |
- Source:
Returns:
If sections
is
given, the KssStyleGuide
object is returned to allow chaining of methods.
Otherwise, the exact KssSection requested, an array of KssSection objects
matching the query, or false is returned.
- Type
- KssStyleGuide | KssSection | Array.<KssSection> | boolean
toJSON() → {Object}
Return the KssStyleGuide
as a JSON object.
- Source:
Returns:
A JSON object representation of the KssStyleGuide.
- Type
- Object