diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000000..ba26f5568a --- /dev/null +++ b/.clang-format @@ -0,0 +1,15 @@ +--- +Language : Cpp +# BasedOnStyle : GNU +AlwaysBreakAfterReturnType: TopLevelDefinitions +AlwaysBreakTemplateDeclarations: true +BraceWrapping: + SplitEmptyFunction: false +ColumnLimit: 130 +IndentPPDirectives: AfterHash +PointerAlignment: Left +SortIncludes: false +SortUsingDeclarations: false +SpaceBeforeParens: ControlStatements +Standard: Cpp11 +... diff --git a/.gitattributes b/.gitattributes index 70faca108b..7d845e399e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,14 @@ +# currently empty attributes (using pre-commit) +[attr]cppfiles +[attr]cfiles +[attr]pyfiles +*.cpp cppfiles +*.cxx cppfiles +*.h cppfiles +*.inl cppfiles +*.txx cppfiles +*.c cfiles +*.py pyfiles *.v -text -diff *.s -text -diff *.scn -text -diff diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..c5655a3205 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,6 @@ +repos: +- repo: git://github.com/doublify/pre-commit-clang-format + rev: master + hooks: + - id: clang-format + files: \.(c|cc|cxx|cpp|h|hpp|hxx|inl|txx) diff --git a/documentation/devel/README.md b/documentation/devel/README.md new file mode 100644 index 0000000000..f3226412f6 --- /dev/null +++ b/documentation/devel/README.md @@ -0,0 +1,8 @@ +# Information specific for developers + +Please check files here for information/code practices for developers. + +- Do read our [contribution guidelines](../../CONTRIBUTING.md) +- Set your editor settings appropriately: [instructions](editor-settings.md) +- Install git hooks for serious development: [instructions](git-hooks.md) +- Read the documentation, including the STIR developers guide \ No newline at end of file diff --git a/documentation/devel/editor-settings.md b/documentation/devel/editor-settings.md new file mode 100644 index 0000000000..999f00a84d --- /dev/null +++ b/documentation/devel/editor-settings.md @@ -0,0 +1,5 @@ +# Developer documentation: editor settings + +White-spaces and indentation with multiple developers are a pain. Please adhere to +our white-space policy, which we try to enforce via [clang-format](https://clang.llvm.org/docs/ClangFormat.html). +Check that site for integration with your editor/IDE. diff --git a/documentation/devel/git-hooks.md b/documentation/devel/git-hooks.md new file mode 100644 index 0000000000..28ec3a5d86 --- /dev/null +++ b/documentation/devel/git-hooks.md @@ -0,0 +1,28 @@ +# Developer documentation: how to install (software for) git hooks + +You first need to have Python and pip + +## Install [pre-commit](https://pre-commit.com) +See https://pre-commit.com/#install but the following might work. + + pip install pre-commit + +If this fails with a permission error, try adding `--user` to the command. + +If that fails with a message about `PyYAML` and `distutils`, try + + pip install --ignore-installed PyYAML + +## Install clang-format +### debian/Ubuntu + sudo apt install clang-format +### MacOS + brew install clang-format +### Others +search the internet and tell us + +## Enable pre-commit hooks +```sh +cd /whereever/STIR +pre-commit install +```