Skip to content
This repository was archived by the owner on May 5, 2024. It is now read-only.

Commit a551616

Browse files
committed
0.4.0
1 parent ff9b51e commit a551616

5 files changed

Lines changed: 35 additions & 19 deletions

File tree

lib/Section.js renamed to Documentation.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
var marked = require('marked');
22

3-
var docHeaderRegex = /^\s*-{3,}\n([\W\w]+?)\n\s*-{3,}/;
4-
var docHeaderLineRegex = /([A-z][\w-]*)\s*:\s*([^\n]+)/g;
3+
var headerRegex = /^\s*-{3,}\n([\W\w]+?)\n\s*-{3,}/;
4+
var headerLineRegex = /([A-z][\w-]*)\s*:\s*([^\n]+)/g;
55

66
function titleToName(string) {
77
return string.replace(/\s+/g, '_').replace(/[^A-z0-9_]/g, '').toLowerCase();
88
}
99

10-
function Section(node) {
10+
function Documentation(node) {
1111
var self = this;
1212

1313
if (node.type === 'comment') {
14-
self.content = marked(node.text.replace(docHeaderRegex, function (headerMatch, lines) {
15-
lines.replace(docHeaderLineRegex, function (headerLineMatch, name, value) {
14+
self.content = marked(node.text.replace(headerRegex, function (headerMatch, lines) {
15+
lines.replace(headerLineRegex, function (headerLineMatch, name, value) {
1616
self[name] = value.trim();
1717
});
1818

@@ -29,8 +29,8 @@ function Section(node) {
2929
var hash = {};
3030

3131
node.walkComments(function (comment) {
32-
if (docHeaderRegex.test(comment.text)) {
33-
var section = new Section(comment);
32+
if (headerRegex.test(comment.text)) {
33+
var section = new Documentation(comment);
3434

3535
hash[section.title] = section;
3636
}
@@ -47,7 +47,7 @@ function Section(node) {
4747
var parent = hash[title];
4848

4949
if (!parent) {
50-
parent = hash[title] = new Section(section.css.clone({ text: '' }));
50+
parent = hash[title] = new Documentation(section.css.clone({ text: '' }));
5151

5252
parent.title = title;
5353
parent.name = titleToName(title);
@@ -61,4 +61,4 @@ function Section(node) {
6161
}
6262
}
6363

64-
module.exports = Section;
64+
module.exports = Documentation;

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,22 @@ grunt.initConfig({
108108
});
109109
```
110110

111+
## Options
112+
113+
#### `theme`
114+
115+
Type: `NPM Repository`
116+
Default: `require('mdcss-theme-github')`
117+
118+
The mdcss theme that you would like to use.
119+
120+
#### `destination`
121+
122+
Type: `String`
123+
Default: `'styleguide'`
124+
125+
The directory that you would like your style guide written to.
126+
111127
[ci]: https://travis-ci.org/jonathantneal/mdcss
112128
[ci-img]: https://img.shields.io/travis/jonathantneal/mdcss.svg
113129
[npm]: https://www.npmjs.com/package/mdcss

index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
var Section = require('./lib/Section.js');
1+
var Documentation = require('./Documentation.js');
22

33
module.exports = require('postcss').plugin('mdcss', function (opts) {
44
opts = opts || {};
55

6-
opts.theme = opts.theme || require('mdcss-theme-github');
7-
opts.directory = opts.directory || 'styleguide';
8-
opts.template = opts.template || 'template.ejs';
9-
opts.index = opts.index || 'index.html';
6+
opts.theme = opts.theme || require('mdcss-theme-github');
7+
opts.destination = process.cwd() + '/' + (opts.destination || 'styleguide');
108

119
return function (css, result) {
12-
var section = new Section(css);
10+
var documentation = new Documentation(css);
1311

14-
if (typeof opts.theme === 'function') opts.theme(section, opts, result);
12+
if (typeof opts.theme === 'function') opts.theme = opts.theme();
13+
14+
if (typeof opts.theme === 'object' && typeof opts.theme.process === 'function') return opts.theme.process(documentation, opts.destination, result);
1515
else result.warn('The theme failed to load.');
1616
};
1717
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mdcss",
3-
"version": "0.3.0",
3+
"version": "0.4.0",
44
"description": "Easily create and maintain style guides with CSS comments using Markdown",
55
"keywords": [
66
"postcss",

test/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ var tests = {
33
'basic': {
44
message: 'supports basic usage',
55
options: {
6-
theme: require('mdcss-theme-github'),
7-
directory: 'test/styleguide'
6+
theme: require('mdcss-theme-github'),
7+
destination: 'test/styleguide'
88
}
99
}
1010
}

0 commit comments

Comments
 (0)