From e0831d35b1c9e33b3751ece132b9f9f7dc0225cd Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Thu, 5 Oct 2017 15:19:02 -0700 Subject: [PATCH] Add pre-commit metadata to doctoc This enables doctoc to be integrated seamlessly with the following [pre-commit](http://pre-commit.com) configuration: ```yaml repos: - repo: https://github.com/thlorenz/doctoc sha: ... # substitute a tag here hooks: - doctoc ``` --- .pre-commit-hooks.yaml | 5 +++++ README.md | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 .pre-commit-hooks.yaml diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 0000000..5fc3acd --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,5 @@ +- id: doctoc + name: doctoc + language: node + entry: doctoc + types: [markdown] diff --git a/README.md b/README.md index 353fc5b..8171c1e 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ by github or other sites via a command line flag. - [Specifying a custom TOC title](#specifying-a-custom-toc-title) - [Specifying a maximum heading level for TOC entries](#specifying-a-maximum-heading-level-for-toc-entries) - [Printing to stdout](#printing-to-stdout) + - [Usage as a `git` hook](#usage-as-a-git-hook) @@ -138,3 +139,19 @@ By default, You can print to stdout by using the `-s` or `--stdout` option. [ack]: http://beyondgrep.com/ + +### Usage as a `git` hook + +doctoc can be used as a [pre-commit](http://pre-commit.com) hook by using the +following configuration: + +```yaml +repos: +- repo: https://github.com/thlorenz/doctoc + sha: ... # substitute a tagged version + hooks: + - id: doctoc +``` + +This will run `doctoc` against markdown files when committing to ensure the +TOC stays up-to-date.