Introduction
If you have embarked upon the task of building your own theme, you’ll be pleased to know SassDoc comes with some extra tools for theme builders. These filters add some features to SassDoc by post-processing the data.
Extras can be added by requiring sassdoc-extras
, calling the extra function on it, and passing it the context object.
For example, to use the Markdown extra:
To use multiple extras, you can “chain” them like this:
Markdown (markdown
)
You may have noticed most descriptions from annotations are parsed as Markdown. This is thanks to the Markdown filter from sassdoc-extras (using Marked). This filter overrides the provided values.
For example, This is some `code`.
becomes This is some <code>code</code>
.
Display toggle (display
)
The display
filter allows you to display items based on their visibility (access level: public
or private
). This filter removes items that should not be displayed.
The display
filter uses the display.access
key from the context configuration to determine if an item should be displayed or not.
Note: it’s always best to define an access level.
Groups aliases (groupName
)
The groupName
filter allows you to define aliases for group slugs (see reference). When using @group
annotation in your SassDoc comments, you usually define a slug (a lowercase string without spaces). If you want your theme to display pretty titles, you can map those slugs to human-friendly names by setting a groups
key in your context configuration.
Note: The groupName
filter overrides the default group
key for each item.
Example: Default group
key:
Example: After using groupName
filter:
Shortcut icon (shortcutIcon
)
The shortcutIcon
filter takes the eponymous key from the configuration and converts it into an object with type
, url
and path
keys.
Result of using a URL http://absolute.path/to/icon.png
in ctx.shortcutIcon
:
Result of using a relative path relative/path/to/icon.png
in ctx.shortcutIcon
:
Sort (sort
)
The sort
filter sorts the items from a sort
configuration value.
Supported criteria:
The sort order is determined by the last character: >
(desc) or <
(asc).
Description (description
, descriptionPath
)
This filter introduces the description
and descriptionPath
configuration keys.
The description
key contains raw description text. The descriptionPath
contains the path to a file containing the description.
Note: using descriptionPath
will override the description
key.
The descriptionPath
is relative to the configuration file, and has no required format.
Note: if the markdown
filter is called after the description
filter, it will parse the description value as Markdown.
Resolved variables (resolveVariables
)
The resolveVariables
filter attempts to connect aliased variable to their
original value. This might be useful for previewing certain types of values,
e.g. colors. Variable aliases can be used in different contexts: variables,
map properties, mixin and function parameters. While the original value
is left untouched there’s a new resolvedValue
key being added.
Example: default data for a variable item.
Example: result after using the resolveVariables
filter.