From 6db1fc3f515d5527e7dbab230e1520cf8a26f1ae Mon Sep 17 00:00:00 2001 From: Daljit Singh Date: Wed, 5 Jul 2023 19:53:11 +0100 Subject: [PATCH] Add doc for using clang-format hook --- CONTRIBUTING.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index aa2ead2e6e..f81ef7605f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -307,6 +307,25 @@ A few explicit notes on such: introduce Windows-style newline characters ("`CR LF`" / "`\r\n`") will need to be edited accordingly. +- In C++, we use [clang-format](https://clang.llvm.org/docs/ClangFormat.html) 16 + to ensure that all C++ code is formatted using the same conventions. + To comply with this requirement, we recommend that you install a local git hook + using [pre-commit](https://pre-commit.com/): + + - Install `pre-commit` via `pip install pre-commit` (or via your OS package manager). + + - Run `pre-commit install` in the source directory of MRtrix. + NOTE: you may need to add the pip scripts folder to your `PATH` + (you can check where pip has installed the package using `pip show pre-commit`). + + This procedure will install a local git hook to ensure that all of your commits + are correctly formatted. If this isn't the case, the commit will fail and an + automatic formatting of the staged changes will be applied. You will then have + to commit those changes again. + + Alternatively, you may wish to configure your editor to automatically format + your code using clang-format. + - In Python, variable / class / module names are enforced through `pylint`. Script "`run_pylint`" in the *MRtrix3* root directory will test any code modifications against these expectations.