npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grunt-doctoc

v0.1.1

Published

Why does this grunt plugin not exist yet?

Downloads

58

Readme

grunt-doctoc

Why does this grunt plugin not exist yet? Perhaps because bitbucket has a [TOC] tag.

Look, this is generated by the plugin:

Table of Contents

Also, the repo of the doctoc script is: https://github.com/thlorenz/doctoc

Getting Started

This plugin requires Grunt ~0.4.5

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, you may install this plugin with this command:

npm install grunt-doctoc --save-dev

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

grunt.loadNpmTasks('grunt-doctoc');

The "doctoc" task

Overview

In your project's Gruntfile, add a section named doctoc to the data object passed into grunt.initConfig().

grunt.initConfig({
  doctoc: {
    options: {
        bitbucket: false,
        target: "./README.md",
        removeAd: true,
        header: "## Table of Contents"
    },
    your_target: {
        // doctoc is a multi task, so create one like this
    },
  },
});

Options

options.target

Type: String Default value: './README.md'

Point to a single file. It gets the doctoc treatment. This means, unless already added, the following tags will be prepended to your file:

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

**Table of Contents**
...

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

The toc will be between the tags. After re-running, the toc will be placed between the tags again. Copy the above one if you want.

Oh yeah, bitbucket currently (2014-07-25) shows html entities as strings. Enjoy the html tags.

options.header

Type: String Default value: "**Table of Contents**"

You can change the header with this. The doctoc script hardcoded prints out this default header, so this is the option to swap that line. Oh yeah, the plugin just does str-replace of the first hit, so I recommend keeping your toc on top of the file, or not using the exact string "**Table of Contents**" in your md.

options.bitbucket

Type: Boolean Default value: false

Outputs TOC in bitbucket format. In case you do not want the automatically generated [TOC] one, I guess. I swear, they should at least add that feature to the bitbucket markdown demo page.

options.removeAd

Type: Boolean Default value: true

By default, the doctoc script will add a message saying it is generated with DocToc. Screw that. So much free software on github that does without. Set it to false to make it show up again.

Usage Examples

Default Options

Assuming you have a README.md file in your base directory, the default options should do well. Since it's a multitask, you probably want to create an empty object regardless. Oh yeah, the default header is bold text, so... suppose you want that to be another header:

grunt.initConfig({
  doctoc: {
    options: {
      header: "## Table of contents"
    },
    readme: {}
  },
});

Custom Options

If you want to use it on several files, for instance ./doc/README.md and ./wiki/index.md, you can do:

grunt.initConfig({
  doctoc: {
    options: {
      header: "## Table of contents"
    },
    doc: {
      options: {
        target: "./doc/README.md"
      }
    },
    wiki: {
      options: {
        target: "./wiki/index.md"
      }
    }
  },
});

Contributing

Sure, add/fix whatever you want.

Release History

(Nothing yet)