Introduction

If you haven’t used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use grunt plugins. Once you’re familiar with that process, install this plugin with this command:

npm install --save-dev grunt-sassdoc

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-sassdoc');

Tip: the load-grunt-tasks module makes it easier to load multiple grunt tasks.

Run the task:

grunt sassdoc

Task targets, files and options may be specified according to the Grunt Configuring tasks guide.

Options

Any specified option will be passed through directly to SassDoc, thus you can specify any option that SassDoc supports. Refer to:

Heads up: if options or a config file are passed it will prevail over .sassdocrc if any. You should really manage your options in one place.

Examples

See the Gruntfile in the repository for full examples.

Bare minimum example.

grunt.initConfig({
  sassdoc: {
    default: {
      src: 'path/to/source',
    },
  },
});

Example with an external configuration file.

grunt.initConfig({
  sassdoc: {
    default: {
      src: 'path/to/source',
      options: {
        config: 'path/to/config.json',
      },
    },
  },
});

Example with some options passed in.

// Tip: you're not required to pass every options,
// just set the one you need.
grunt.initConfig({
  sassdoc: {
    default: {
      src: 'path/to/source',
      options: {
        dest: 'path/to/docs',
        display: {
          access: ['public', 'private'],
          alias: true,
          watermark: true,
        },
        groups: {
          slug: 'Title',
          helpers: 'Helpers',
          hacks: 'Dirty Hacks & Fixes',
          'undefined': 'Ungrouped',
        },
        basePath: 'https://github.com/SassDoc/grunt-sassdoc',
      },
    },
  },
});

Events

This task will emit a start event when compilation begins, and a done event on completion. This is useful if you would like simple notifications about the compile process.

Caution! The start and done events are not intended for replacing the standard Grunt API for configuring and running tasks.

Here is a simple example using them:

// Examples using start and done events.
grunt.event.on('sassdoc.start', function (target, src) {
  grunt.log.writeln(target + ': compiling ' + src);
});

grunt.event.on('sassdoc.done', function (target, src) {
  grunt.log.writeln(target + ': done');
});