Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dumux-repositories
dumux
Commits
4f9e5ddd
Commit
4f9e5ddd
authored
May 22, 2018
by
Timo Koch
Browse files
[doc] Add preliminary contribution guide and style guide
parent
cb9740ba
Changes
2
Hide whitespace changes
Inline
Side-by-side
CONTRIBUTING.md
0 → 100644
View file @
4f9e5ddd
# Contribution guidelines for DuMu<sup>x</sup>
## Style guide
When contributing code to DuMu
<sup>
x
</sup>
please follow the
[
styleguide
](
doc/styleguide.md
)
.
doc/styleguide.md
0 → 100644
View file @
4f9e5ddd
# Style guide
## File system
*
Try to order your new header into the existing directory structure
*
Headers are named like the classes they contain (usually one class per file, exception: closely tied helper classes / functions)
*
Headers are names lower case only (using underscores only if absolutely necessary for readability)
*
Folder names are lower case only
*
Tests should be called after model and discretization scheme using underscores and lower case only, e.g.
__Example:__
```
test_1p_tpfa
test_2p2c_box_infiltration
```
## C++
### Indent
*
The default indent is 4 spaces (no tabs, not 2 spaces)
### Formatting
*
Curly brackets that open or close a scope are on a separate line (except for
[
namespaces
](
#Namespaces
)
)
*
There should be a space between
`if`
,
`else if`
,
`switch`
and the condition
*
`if`
,
`else if`
,
`switch`
can omit brackets if the expression is only one line
```
c++
// comment for if block, space between if and (enableGravity)
if
(
enableGravity
)
{
Scalar
b
=
1.0
;
return
b
*
gravity_
[
dimWorld
-
1
];
}
// comment for else-block
else
return
1.0
;
// ok, one-liner
```
### Namespaces
*
Open curly brackets on the same line
*
Do not indent the code inside the namespace
*
Comment closing curly brackets uniquely
__Example:__
```
c++
namespace
Dumux
{
namespace
Properties
{
bool
here
=
true
;
bool
nothere
=
false
;
// not like this
}
// end namespace Properties
}
// end namespace Dumux
```
### Includes
*
Space between
`#include`
and path
*
C++ standard library includes first, then Dune, then others, then DuMu
<sup>
x
</sup>
*
Always use project relative paths
-
exception: the other header is in the same folder and closely related (
`#include "volumevariables.hh"`
)
```
c++
#include
<type_traits>
#include
<dune/common/fvector.hh>
#include
<dumux/common/exceptions.hh>
```
### Documentation
*
Prefer long-style doxygen documentation of the form
*
at least containing a
`\brief`
```
c++
/*
* \brief Base class for all linear solvers
*/
```
*
document all parameters of functions and what it returns
*
optionally document which error the function might throw
### Classes
TODO
#### Member functions
TODO
#### Private data member
*
Use underscore postfix
```
c++
...
private
:
int
steps_
;
...
```
### Functions
TODO
### Property system
*
Prefer class templates with regular template arguments over class templates with a
`TypeTag`
as template argument
TODO
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment