ADD `.clang-format` for convenience
It might be handy to add a .clang-format with your (doxide) preferred formatting style.
When I added something as a PR, I noticed that my global .clang-format file was picked up when saving the modified file in the PR.
Yes, good idea @jkhoogland, let me do that in a future iteration.
I can take this issue up to ease development and contribute a .clang-format file: which style do you use/suggest?
Furthermore, how about adding an .editorconfig file? I notice, for example, the top CMakeLists.txt has non-consistent indenting here and here. At least, an .editorconfig file helps keeping contributors aligned. This is not as nearly as detailed as a .clang-format, but supported by many editors and works on virtually file (C++, CMake, Bash, YAML, ...) to ensure a consistent formatting across all files.
Thanks @alberto-scolari. I have a .clang-format lying around from another project, and I've just added that. It's as close as I can get to my preferred style. I'm not familiar with .editorconfig but happy to accept a PR with that.
Short story:
- K&R brace style.
- Indenting with two spaces, no tabs.
- Wrap at 78 characters (but sometimes rules need to be broken).
I realise there are some inconsistencies in the current codebase. I try not to get too pedantic with new contributors as long as the code is neat. And, as @jkhoogland originally suggested, this file should help with that.
Additional pedantry that, if I recall correctly, I tried to encode in this .clang-format, but is more personal style than essential:
- When wrapping, I like to indent four spaces but only once, with line breaks after operators, e.g.
if (something1 && something2 && something3 && something4 && something5 && is_this_true( some_var) && something6) { // ... } - I like to put spaces around low-precedence operators but not high-precedence operators, as it makes code more readable to me. So you'll see me write
a*b + cinstead ofa*b+cora * b + c.
But again, this is more personal style, and if it works for contributors then great, but the K&R and indenting with two spaces is the main thing.