Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configuration for white-space #724

Merged
merged 5 commits into from
May 27, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -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
...
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Check
on:
- push
- pull_request
jobs:
check:
runs-on: ubuntu-latest
name: pre-commit
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- run: sudo apt-get install -yqq clang-format
- uses: pre-commit/action@v2.0.0
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
repos:
- repo: git://github.com/doublify/pre-commit-clang-format
rev: master
KrisThielemans marked this conversation as resolved.
Show resolved Hide resolved
hooks:
- id: clang-format
files: \.(c|cc|cxx|cpp|h|hpp|hxx|inl|txx)$
8 changes: 8 additions & 0 deletions documentation/devel/README.md
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions documentation/devel/editor-settings.md
Original file line number Diff line number Diff line change
@@ -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.
28 changes: 28 additions & 0 deletions documentation/devel/git-hooks.md
Original file line number Diff line number Diff line change
@@ -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
```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you need to work with a branch that was forked prior to in inclusion of clang-format, you will need to temporarily disable/uninstall pre-commit again:

    pre-commit uninstall

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or git commit --no-verify

KrisThielemans marked this conversation as resolved.
Show resolved Hide resolved