Auto-generate style documentation from your CSS using Jekyll and DSS.
This project is small template for creating a style guide or pattern library or style documentation or whatever you want to call it. It uses DSS to parse JSDoc style comments in your CSS and then uses Jekyll to build the page.
npm install
grunt dss
jekyll serve
Document your CSS with JSDoc style comments using DSS. You can use CSS, Sass, Less, Stylus, whatever you want. Sass compilation is built into Jekyll, so that is what this example project is using.
Example:
/**
* @name Buttons
* @description This is an example of a button
* @markup
* <button class="button">Button</button>
*/
.button {}
Update the dss
task in the Gruntfile.js
to point at your documented stylesheets. The destination should be the _data
folder so Jekyll can read when rendering.
Example:
dss: {
build: {
files: {
"_data/styles.json": "_sass/**.*"
}
}
}
Run grunt dss
The table of contents is found in _includes/table-of-contents.html
and the template for each block is in _includes/component.html
. The basic data for a block is:
{
"name": "Buttons",
"description": "This is an example of a button",
"markup": {
"example": "<button class=\"button\">Button</button>",
"escaped": "<button class=\"button\">Button</button>"
}
}
You can access it in Jekyll with code like:
<h2>{{ block.name }}</h2>
<p>{{ block.description }}</p>
<h3>Example</h3>
<div>{{ block.markup.example }}</div>
jekyll server
And that's all!