diff --git a/docs/Documentation.md b/docs/Documentation.md index 2f501425f0..8990f977dc 100644 --- a/docs/Documentation.md +++ b/docs/Documentation.md @@ -1068,6 +1068,20 @@ Exclusion applies both to formatting and the format checking. See [CodeFormatter.fsi](../src/Fantomas/CodeFormatter.fsi) to view the public API of Fantomas. +## A git pre-commit hook sample + +A very elegant and transparent way to use Fantomas is including it in a pre-commit git hook, by creating a `.git/hooks/pre-commit` file with: + +``` +#!/bin/sh +git diff --cached --name-only --diff-filter=ACM -z | xargs -0 $HOME/.dotnet/tools/fantomas +git diff --cached --name-only --diff-filter=ACM -z | xargs -0 git add +``` + +This script assumes you have installed Fantomas globally as a [dotnet tool](https://www.nuget.org/packages/fantomas-tool/) + +**Please use with caution** as [Fantomas is not without bugs](https://github.com/fsprojects/fantomas/issues?q=is%3Aissue+is%3Aopen+label%3A%22bug+%28soundness%29%22). + ## FAKE Helpers Fantomas also exposes some less official helper functions when formatting code in FAKE scripts.