|
|
In order to obtain a unified code formatting and minimize changes in commits due to different formattings, we used [clang-format](https://clang.llvm.org/docs/ClangFormat.html) to format the source code of duneuro.
|
|
|
#### Installation
|
|
|
Under Ubuntu (and also Debian, etc) clang-format can be installed as usual by calling
|
|
|
```bash
|
|
|
sudo apt install clang-format
|
|
|
```
|
|
|
#### Setup
|
|
|
The style for formatting the source code can be configured using a configuration file, which is attached to this wiki page ([.clang-format](uploads/469a62ef229f6f16bc0478a4c86dcbe9/.clang-format)).
|
|
|
Download the file and place it into a folder above your duneuro-directory. E.g. if all your Dune modules are located in the directory `/home/user/Dune` you can place the .clang-format file into this directory as well, or simply into your home directory.
|
|
|
#### Usage
|
|
|
In order to reformat a file `file_to_format.hh` in-place, you can call
|
|
|
```bash
|
|
|
clang-format -style=file -i file_to_format.hh
|
|
|
```
|
|
|
Note that if your opened the file in an editor, you have to save your changes and make sure to reload the file after reformatting. The option `-style=file` will load the style parameters from a .clang-format file in one of the parent directories of the source file. The option `-i` will perform the reformatting in-place. If you just want to look at the reformatted file without applying any changes or store the output into a different file, you can ommit the `-i`. |
|
|
\ No newline at end of file |