# grunt-csstoc

> Generate table of contents for CSS files

Latest version **0.2.0** (published 2013-07-03) · 0 weekly downloads

## Install

```sh
npm install grunt-csstoc
pnpm add grunt-csstoc
yarn add grunt-csstoc
bun add grunt-csstoc
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2013-07-03 |
| First published | 2013-07-01 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.8.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Benno Mielke |
| Maintainers | webinfluenza |
| Keywords | gruntplugin |

## Links

- npm: https://www.npmjs.com/package/grunt-csstoc
- Repository: https://github.com/webinfluenza/grunt-csstoc
- Issues: https://github.com/webinfluenza/grunt-csstoc/issues
- npm.io page: https://npm.io/package/grunt-csstoc

## Recent versions

- 0.2.0 (latest) — 2013-07-03
- 0.1.0 — 2013-07-01

## README

# grunt-csstoc

> Generate table of contents (TOC) for CSS files (also works with **LESS** and **SASS**)

## Getting Started
This plugin requires Grunt `~0.4.0`

If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

```shell
npm install grunt-csstoc --save-dev
```

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

```js
grunt.loadNpmTasks('grunt-csstoc');
```

## The "csstoc" task

### Overview
In your project's Gruntfile, add a section named `csstoc` to the data object passed into `grunt.initConfig()`.

```js
grunt.initConfig({
  csstoc: {
    dist: {
      options: {
        // Task-specific options go here.
      },
      files: {
        // your files here
      }
    }
  },
})
```

### Options

#### options.sectionString
Type: `String`
Default value: `'section'`

A string value that is used to do identify TOC entries.

#### options.tocHead
Type: `String`
Default value: `'Table Of Contents'`

A string value that is used as headline for the TOC

### Usage Examples

#### Default Options
In this example, the PlugIn will read all the `@tocitem` entries from the CSS file and generates the TOC from these entries.

```js
grunt.initConfig( {
  csstoc: {
    dist: {
      options: {
        sectionString: 'tocitem',
        tocHead: 'Table Of Contents'
      },
      files: {
        'dest/mycss.css': 'src/mycss.css',
      },
    }
  },
} )
```

#### CSS File
How the TOC entries should look like:
```css
/**
 * @section 1. Foo
 **/

.foo {
    height: 20px
}

/**
 * @section 2. Bar
 **/

/**
 * @section 2.1 Subentry
 **/
.foo .bar {
    background-color: red
}
```

## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).

## Release History
* 2013-07-03   v0.2.0   Included grunt watch task, option for TOC head string
* 2013-06-30   v0.1.0   First official release, still **BETA**

---
_Source: https://npm.io/package/grunt-csstoc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
