├── .gitignore
├── .jshintrc
├── Gruntfile.js
├── README.md
├── package.json
├── tasks
├── data
│ ├── highlight.docco.css
│ ├── highlight.github.css
│ ├── highlight.monokai.css
│ ├── highlight.solarized-dark.css
│ ├── highlight.solarized-light.css
│ ├── highlight.xcode.css
│ ├── scripts.js
│ ├── template.hbs
│ └── theme.css
├── libs
│ └── sassdown.js
└── sassdown.js
└── test
├── custom
└── assets
│ ├── css
│ └── application.css
│ └── sass
│ ├── application.sass
│ ├── base
│ ├── _base.sass
│ └── _variables.sass
│ └── modules
│ └── _media.sass
├── example
└── assets
│ ├── css
│ ├── screen.css
│ ├── theme.css
│ └── webfonts.css
│ ├── js
│ └── script.js
│ └── sass
│ ├── partials
│ ├── base
│ │ ├── _headings.scss
│ │ ├── _preformatted.scss
│ │ └── _typography.scss
│ ├── comments
│ │ ├── _comments-sass.sass
│ │ └── _comments-scss.scss
│ ├── modules
│ │ └── _navigation.scss
│ └── objects
│ │ ├── common
│ │ ├── _circular.scss
│ │ ├── _clearfix.scss
│ │ ├── _vertical-middle.scss
│ │ └── _visual-hide.scss
│ │ ├── excluded
│ │ └── _balerts.scss
│ │ └── user
│ │ ├── _alerts.scss
│ │ └── _buttons.scss
│ ├── readme.md
│ └── screen.scss
└── helpers
├── handlebars.lowercase.js
└── nested-helpers
└── handlebars.uppercase.js
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | Thumbs.db
3 | test/custom/styleguide
4 | test/example/styleguide
5 | node_modules
6 | npm-debug.log
7 | tmp
8 |
--------------------------------------------------------------------------------
/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "bitwise": true,
3 | "camelcase": true,
4 | "curly": true,
5 | "eqeqeq": true,
6 | "immed": true,
7 | "indent": 4,
8 | "latedef": true,
9 | "newcap": true,
10 | "noempty": true,
11 | "quotmark": "single",
12 | "undef": true,
13 | "unused": true,
14 | "trailing": true,
15 | "eqnull": true,
16 | "browser": true,
17 | "jquery": true,
18 | "node": true,
19 | "devel": true,
20 | "globals": {
21 | "grunt": true
22 | }
23 | }
--------------------------------------------------------------------------------
/Gruntfile.js:
--------------------------------------------------------------------------------
1 | /*
2 | * sassdown
3 | * github.com/nopr/sassdown
4 | *
5 | * Copyright (c) 2013 Jesper Hills, contributors
6 | * Some rights reserved
7 | */
8 |
9 | 'use strict';
10 |
11 | module.exports = function(grunt) {
12 |
13 | // Project configuration.
14 | grunt.initConfig({
15 |
16 | jshint: {
17 | all: [
18 | 'Gruntfile.js',
19 | 'tasks/libs/sassdown.js',
20 | 'tasks/sassdown.js',
21 | ],
22 | options: {
23 | jshintrc: '.jshintrc',
24 | },
25 | },
26 |
27 | test: 'xxx',
28 |
29 | // Before generating any new files, remove any previously-created files.
30 | clean: {
31 | example: ['test/*/styleguide/'],
32 | },
33 |
34 | // Configuration to be run (and then tested).
35 | sassdown: {
36 | defaultStyleguide: {
37 | options: {
38 | assets: [
39 | 'test/example/assets/css/*.css',
40 | 'test/example/assets/js/*.js',
41 | ],
42 | readme: 'test/example/assets/sass/readme.md',
43 | //handlebarsHelpers: ['test/helpers/**/*.js'],
44 | //theme: 'test/theme.css',
45 | //template: 'test/template.hbs'
46 | //highlight: 'github'
47 | },
48 | files: [{
49 | expand: true,
50 | cwd: 'test/example/assets/sass/partials',
51 | src: ['**/*.{scss,sass}'],
52 | dest: 'test/example/styleguide/'
53 | }]
54 | },
55 | customStyleguide: {
56 | options: {
57 | assets: [
58 | 'test/custom/assets/css/*.css'
59 | ],
60 | excludeMissing: true,
61 | readme: false,
62 | commentStart: /\/\* (?:[=]{4,}\n[ ]+|(?!\n))/,
63 | commentEnd: /[ ]+[=]{4,} \*\//
64 | },
65 | files: [{
66 | expand: true,
67 | cwd: 'test/custom/assets/sass',
68 | src: ['**/*.sass'],
69 | dest: 'test/custom/styleguide/'
70 | }]
71 | }
72 |
73 | },
74 |
75 | });
76 |
77 | // Actually load this plugin's task(s).
78 | grunt.loadTasks('tasks');
79 |
80 | // These plugins provide necessary tasks.
81 | grunt.loadNpmTasks('grunt-contrib-jshint');
82 | grunt.loadNpmTasks('grunt-contrib-clean');
83 | grunt.loadNpmTasks('grunt-contrib-nodeunit');
84 |
85 | // By default, lint and run all tests.
86 | grunt.registerTask('default', ['clean', 'jshint', 'sassdown']);
87 |
88 | };
89 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # sassdown
2 |
3 | > Grunt plugin for building living styleguides with Handlebars from Markdown comments in CSS, Sass and LESS files.
4 |
5 | **Note: *This plugin is in semi-active development!* So expect it to be a little rough around the edges. If you have any questions, issues or suggestions get in touch. Currently on version `0.2.7`.**
6 |
7 | 1. [Getting started](#getting-started)
8 | 2. [Sassdown task](#sassdown-task)
9 | - [Overview](#overview)
10 | - [Options](#options)
11 | - [Usage](#usage)
12 | 3. [Markdown](#markdown)
13 | 4. [Handlebars](#handlebars)
14 | 5. [Highlight.js](#highlightjs)
15 | 6. [Data Objects](#data-objects)
16 | - [Page](#page)
17 | - [Pages](#pages)
18 | 7. [Template](#template)
19 | 8. [Sass](#sass)
20 |
21 | ### What's new in version 0.2.7?
22 |
23 | - Path resolving is relative; no more issues serving from localhost or using file:// protocols
24 | - Whitespace and preformatting is preserved in markup results
25 | - Source styles shown in conjunction with markup and result
26 | - Pages are served form an array-literal node tree; meaning clearer and nested navigation
27 | - Comment block matching is modifiable via regular expressions
28 | - Choice of syntax highlighting styles from various popular Highlight.js themes
29 | - Syntax highlighting is done with Node before templates compile; faster page loads
30 |
31 | ## Getting started
32 |
33 | Install this plugin with this command:
34 |
35 | ```bash
36 | npm install sassdown --save-dev
37 | ```
38 |
39 | Enabled inside your Gruntfile with this line of JavaScript:
40 |
41 | ```js
42 | grunt.loadNpmTasks('sassdown');
43 | ```
44 |
45 | ## Sassdown Task
46 |
47 | Run the task using `grunt sassdown`. Task targets, files and options may be specified according to the grunt [configuring tasks](http://gruntjs.com/configuring-tasks) guide.
48 |
49 | ### Overview
50 | In your project's Gruntfile, add a section named `sassdown` to the data object passed into `grunt.initConfig()`.
51 |
52 | ```js
53 | sassdown: {
54 | options: {
55 | // Task-specific options go here.
56 | },
57 | target: {
58 | // Target-specific file lists and/or options go here.
59 | },
60 | },
61 | ```
62 |
63 | ### Options
64 |
65 | #### options.assets
66 | Type: `Array`
67 | Default: `null`
68 |
69 | *Optional*. Array of file paths. Will be included into the styleguide output. Supports [globbing](http://gruntjs.com/configuring-tasks#globbing-patterns). Supports relative and absolute file paths (eg. `http://`, `https://`, `//` or even `file://`).
70 |
71 | #### options.template
72 | Type: `String`
73 | Default: `null`
74 |
75 | *Optional*. A path to a Handlebars template file. Will use default Sassdown template if left blank.
76 |
77 | #### options.handlebarsHelpers
78 | Type: `Array`
79 | Default: `null`
80 |
81 | *Optional*. Array of file paths. The [Handlebars helpers](http://handlebarsjs.com/#helpers) will be available to use in the template. Supports [globbing](http://gruntjs.com/configuring-tasks#globbing-patterns). Supports relative and absolute file paths (eg. `http://`, `https://` or even `file://`).
82 |
83 | #### options.theme
84 | Type: `String`
85 | Default: `null`
86 |
87 | *Optional*. A path to a theme stylesheet. Will use default Sassdown theme if left blank.
88 |
89 | #### options.readme
90 | Type: `String`
91 | Default: `null`
92 |
93 | *Optional*. Path to a README file. When set, this file will be parsed with Markdown and used as the index page for the styleguide.
94 |
95 | #### options.highlight
96 | Type: `String`
97 | Default: `github`
98 |
99 | *Optional*. Choice of syntax highlighting style. Defaults to `github`, but other available options are: `docco`, `monokai`, `solarized-light`, `solarized-dark` or `xcode`.
100 |
101 | #### options.scripts
102 | Type: `Array`
103 | Default: `null`
104 |
105 | *Optional*. Array of file paths. The scripts will be linked with script tags with src attributes. Supports [globbing](http://gruntjs.com/configuring-tasks#globbing-patterns). Supports relative and absolute file paths (eg. `http://`, `https://`, `//` or even `file://`).
106 |
107 | If this option is set the default scripts won't be included, but you can include them again by adding `node_modules/sassdown/tasks/data/scripts.js` to the file list, or by copying and modifying that file.
108 |
109 | #### options.commentStart
110 | Type: `RegExp`
111 | Default: `/\/\*/`
112 |
113 | *Optional*. A regular expression to match beginning part of a comment block. Defaults to regular block comment (`/*`).
114 |
115 | #### options.commentEnd
116 | Type: `RegExp`
117 | Default: `/\*\//`
118 |
119 | *Optional*. A regular expression to match ending part of a comment block. Defaults to regular block comment (`*/`).
120 |
121 | #### options.excludeMissing
122 | Type: `Boolean`
123 | Default: `false`
124 |
125 | *Optional*. When set to true, Sassdown will ignore any files that do not contain matching or valid comment blocks.
126 |
127 | #### options.dryRun
128 | Type: `Boolean`
129 | Default: `false`
130 |
131 | *Optional*. When set to true, Sassdown will not generate any files, and will exit with status `1` if any files do not contain matching or valid comment blocks.
132 |
133 | ### Usage
134 |
135 | You will need to use an [expanded files object](http://gruntjs.com/configuring-tasks#building-the-files-object-dynamically), but here is roughly the minimum configuration required.
136 | ```js
137 | sassdown: {
138 | styleguide: {
139 | options: {
140 | assets: ['public/css/*.css']
141 | },
142 | files: [{
143 | expand: true,
144 | cwd: 'src/sass',
145 | src: ['*.scss'],
146 | dest: 'public/styleguide/'
147 | }]
148 | }
149 | },
150 | ```
151 |
152 | On larger projects you may need to include additional assets and customise the output with a user theme, template and scripts.
153 | ```js
154 | sassdown: {
155 | styleguide: {
156 | options: {
157 | assets: [
158 | 'public/css/**/*.min.css',
159 | 'public/js/*.min.js',
160 | 'http://use.typekit.net/sea5yvm.js',
161 | ],
162 | theme: 'src/styleguide/theme.css',
163 | template: 'src/styleguide/template.hbs',
164 | scripts: ['src/styleguide/*.js'],
165 | readme: 'src/assets/sass/readme.md',
166 | highlight: 'monokai',
167 | excludeMissing: true
168 | },
169 | files: [{
170 | expand: true,
171 | cwd: 'src/assets/sass',
172 | src: [
173 | 'partials/**/*.{scss,sass}',
174 | 'modules/**/*.{scss,sass}'
175 | ],
176 | dest: 'public/styleguide/'
177 | }]
178 | }
179 | },
180 | ```
181 |
182 | # Markdown
183 |
184 | Sassdown uses [Markdown](https://github.com/chjj/marked) to parse any block comments in your Sass files. From these, it generates the text content in the styleguide. Any recognised code blocks will be rendered as HTML/SCSS source-result pairs.
185 |
186 | ## Structure
187 |
188 | You may use any Markdown-compatible [heading syntax](https://github.com/nopr/sassdown/issues/7) you like. You may use any common style of [block-comment syntax](https://github.com/nopr/sassdown/issues/12#issuecomment-28219982) you like. Code blocks may be fenced or indented (four spaces or one tab character). Below are several examples; each will be correctly parsed by Sassdown into identical output.
189 |
190 | ### Example .scss file
191 |
192 | ```scss
193 | /*
194 |
195 | Alerts
196 | ======
197 |
198 | Creates an alert box notification using the `.alert-` prefix. The following options are available:
199 |
200 |