` or an `` element:
```html
Click
Some Page
```
*/
```
```html
Button styles can be applied to any element. Typically you'll want to use
either a <button> or an <a> element:
<button class="btn">Click</button>
<a class="btn" href="/some-page">Some Page</a>
```
The contents of a section may also be imported from another file.
**buttons.md**:
Button styles can be applied to **any** element. Typically you'll want to use
either a `` or an `` element:
```html
Click
Some Page
```
**base.css**:
```css
/*---
title: Buttons
import: buttons.md
---*/
```
The contents of a section may be automatically imported as well. For example, had the `import` been omitted, a sibling file of `base.buttons.md` or `base.md` would have been used (in that order of preference) if they existed.
### Details
Additional heading details are added before a second set of three dashes `---` in a section. These heading details are parsed and added to the [`documentation` object](#documentation-object).
```css
/*---
title: Buttons
section: Base CSS
---
Button styles can be applied to **any** element.
*/
```
```json
{
"title": "Buttons",
"section": "Base CSS",
"content": "Button styles can be applied to any element.
"
}
```
## Writing themes
Creating themes requires an understanding of [creating and publishing npm packages](https://docs.npmjs.com/misc/developers).
The easiest way to create a new theme is to visit the [boilerplate theme] project page, fork and clone it, and then run `npm install`.
To create a theme from scratch; create an `index.js` like this one in a new npm package directory:
```js
module.exports = function (themeopts) {
// initialize the theme
// example usage:
//
// require('mdcss')({
// theme: require('mdcss-theme-mytheme')({ /* opts */ })
// })
// return the theme processor
return function (docs) {
// do things with the documentation object
// remember to use __dirname to target this theme directory
// return a promise
return new Promise(function (resolve, reject) {
// resolve an object with an assets path and a compiled template
resolve({
assets: '', // directory of files to copy
template: '' // contents of style guide to write
});
});
};
};
// this is so mdcss can check whether the plugin has already been initialized
module.exports.type = 'mdcss-theme';
```
The `exports` function is where theme options are initialized.
```js
require('mdcss')({
theme: require('mdcss-theme-mytheme')({ /* theme options */ });
});
```
The `exports` function returns a theme processor. The theme processor is what receives the ordered list of all the parsed `documentation` objects as well as the [options](#options) originally passed into the [mdcss] plugin.
## Documentation object
Each `documentation` object may contain the following properties:
- **title**: The title of the current section of documentation.
- **name**: A unique, hash-safe name of the current section of documentation.
- **section**: The proper title of a parent section.
- **content**: The body copy of the current section of documentation.
- **parent**: The parent section.
- **children**: An array of child sections.
- **context**: The original [`Comment`](https://github.com/postcss/postcss/blob/master/docs/api.md#comment-node) node used to generate the current section of documentation.
- **import**: A path to the file representing the content of the current section of documentation.
In addition to these properties, a `documentation` object includes any additional [details](#details).
```css
/*---
title: Buttons
section: Base CSS
yakkityyak: Don’t Talk Back
---
Button styles can be applied to **any** element.
*/
```
---
Have fun, and thanks for using [mdcss].
[ci]: https://travis-ci.org/jonathantneal/mdcss
[ci-img]: https://img.shields.io/travis/jonathantneal/mdcss.svg
[npm]: https://www.npmjs.com/package/mdcss
[npm-img]: https://img.shields.io/npm/v/mdcss.svg
[boilerplate theme]: https://github.com/jonathantneal/mdcss-theme
[Gulp PostCSS]: https://github.com/postcss/gulp-postcss
[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
[PostCSS]: https://github.com/postcss/postcss
[mdcss]: https://github.com/jonathantneal/mdcss