Updated Clang Format Text Style (markdown) authored by williamfgc's avatar williamfgc
<ol><li><strong>Clang-format:</strong> ADIOS2 uses the clang-format tool to automatically enforce source code style and formatting rules. There are various ways to integrate the clang-format tool into your IDE / Code Editor depending on if you use Emacs, Vim, Eclipse, KDevelop, Microsoft Visual Studio, etc. that are a bit outside the scope of this document but a quick google search for &quot;integrate clang-format&quot; should point you in the right direction. Main points: 1. <strong>Clang-format:</strong> ADIOS2 uses the clang-format tool to automatically enforce source code style and formatting rules. There are various ways to integrate the clang-format tool into your IDE / Code Editor depending on if you use Emacs, Vim, Eclipse, KDevelop, Microsoft Visual Studio, etc. that are a bit outside the scope of this document but a quick google search for &quot;integrate clang-format&quot; should point you in the right direction. Main points:
<ul><li>Lines no longer than 80 characters.</li> * Lines no longer than 80 characters.
<li>Always use braces { and }, even for 1 line <code>if</code> blocks.</li> * Always use braces { and }, even for 1 line <code>if</code> blocks.
<li>Use 4 spaces for indentation.</li><li>However, you can always reformat the code manually by running:</li> * Use 4 spaces for indentation.</li><li>However, you can always reformat the code manually by running:
<li><pre style="border: 0;"><code>clang-format -i <a class="tc-tiddlylink tc-tiddlylink-missing" href="#SourceFile">SourceFile</a>.cpp <a class="tc-tiddlylink tc-tiddlylink-missing" href="#SourceFile">SourceFile</a>.h</code></pre></li></ul></li> ```
clang-format -i SourceFile.cpp SourceFile.h
```
<li><strong>Naming:</strong> Use meaningful English words, well-known acronyms (MPI, XML, CFD, GMRES, etc.), or well-known short names (Config, Comm, 2D, 3D). 2. <strong>Naming:</strong> Use meaningful English words, well-known acronyms (MPI, XML, CFD, GMRES, etc.), or well-known short names (Config, Comm, 2D, 3D).
<ul> <ul>
<li>Examples: <strong>initialTime</strong> instead of <strong>tIni</strong> , or <strong>work</strong> instead of <strong>wrk</strong> </li> <li>Examples: <strong>initialTime</strong> instead of <strong>tIni</strong> , or <strong>work</strong> instead of <strong>wrk</strong> </li>
<li>One Exception: when redefining long types with the <strong>using</strong> keyword reasonable mnemonics and short names are allowed, always document scope. <li>One Exception: when redefining long types with the <strong>using</strong> keyword reasonable mnemonics and short names are allowed, always document scope.
...@@ -16,7 +18,7 @@ using std::vector<std::vector<double>> = vDouble2D; ...@@ -16,7 +18,7 @@ using std::vector<std::vector<double>> = vDouble2D;
</li> </li>
</ul> </ul>
<li><strong>Avoid underscores:</strong> adds unnecessary length. Reserve it for prefixes of special cases (see class members and lambda functions). Use upper case letters instead. 3. <strong>Avoid underscores:</strong> adds unnecessary length. Reserve it for prefixes of special cases (see class members and lambda functions). Use upper case letters instead.
** Don't ** Don't
...@@ -32,7 +34,7 @@ using std::vector<std::vector<double>> = vDouble2D; ...@@ -32,7 +34,7 @@ using std::vector<std::vector<double>> = vDouble2D;
</li> </li>
<li><strong>Using and typedef keywords:</strong> Prefer the keyword <strong>using</strong> over <strong>typedef</strong> for readability. Only rename very long complex or custom types, do not rename standard types ( int , double , std::vector ). Prefer including ADIOSTypes.h as it contains fixed types in the std:: namespace uint8_t, uint64_t . 4. <strong>Using and typedef keywords:</strong> Prefer the keyword <strong>using</strong> over <strong>typedef</strong> for readability. Only rename very long complex or custom types, do not rename standard types ( int , double , std::vector ). Prefer including ADIOSTypes.h as it contains fixed types in the std:: namespace uint8_t, uint64_t .
<ul> <ul>
<li> Don't <li> Don't
...@@ -47,5 +49,4 @@ using std::vector<std::vector<double>> = vDouble2D; ...@@ -47,5 +49,4 @@ using std::vector<std::vector<double>> = vDouble2D;
``` ```
</li> </li>
</ul> </ul>
</li>
</ol>
\ No newline at end of file