-
Notifications
You must be signed in to change notification settings - Fork 130
Documentation/interface convention #380
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
22ca105
Changed numeric list for citation
vkresch 7346fed
Adding interface naming convention
vkresch b3aad5a
Merge branch 'master' into documentation/interface-convention
vkresch 0865d62
Update doc/interfaceconventions.rst
pmai 41c1199
Update doc/interfaceconventions.rst
pmai 387006e
Update doc/interfaceconventions.rst
pmai 9be62d5
Merge branch 'master' into documentation/interface-convention
jdsika 47a0fc6
Merge branch 'master' into documentation/interface-convention
jdsika 2ede67d
Added section about the use of UNKNOWN in GT
jdsika File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| .. _iconventions: | ||
|
|
||
| Interface Conventions | ||
| ====================== | ||
|
|
||
| When adding new messages, enums, field messages and field enums to OSI we enforce a few naming conventions for each type like in the `style guide <https://developers.google.com/protocol-buffers/docs/style>`_ from protobuf. | ||
|
|
||
| Message Naming | ||
| --------------- | ||
| A message definition should always be in camel case. This means that the first letter of each word in a message should be upper case without any spaces. See example below: | ||
|
|
||
| .. code-block:: protobuf | ||
|
|
||
| message EnvironmentalConditions | ||
| { | ||
| } | ||
|
|
||
| Field Message Naming | ||
| --------------------- | ||
| After defining a message custom fields can be added to it in snake case format. This means every letter is lower case and the words are connected through an underline character. See example below: | ||
pmai marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| .. code-block:: protobuf | ||
|
|
||
| message EnvironmentalConditions | ||
| { | ||
| optional double atmospheric_pressure = 1; | ||
| } | ||
|
|
||
pmai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Enum Naming | ||
| ------------ | ||
| The naming of an enum should be camel case. See example below: | ||
|
|
||
| .. code-block:: protobuf | ||
|
|
||
| message EnvironmentalConditions | ||
| { | ||
| optional double atmospheric_pressure = 1; | ||
|
|
||
| enum AmbientIllumination | ||
| { | ||
| } | ||
| } | ||
|
|
||
| Enum Field Naming | ||
| ------------ | ||
| The naming of an enum field should be all in upper case. The start should be converted from the enum name camel case to upper case snake case. It is mandatory to have as a first enum field name the name ``_UNKNOWN`` and as the second the name ``_OTHER`` attached to it. After that the naming can be decided by the user. See example below: | ||
|
|
||
| .. code-block:: protobuf | ||
|
|
||
| message EnvironmentalConditions | ||
| { | ||
| optional double atmospheric_pressure = 1; | ||
|
|
||
| enum AmbientIllumination | ||
| { | ||
| AMBIENT_ILLUMINATION_UNKNOWN = 0; | ||
|
|
||
| AMBIENT_ILLUMINATION_OTHER = 1; | ||
|
|
||
| AMBIENT_ILLUMINATION_LEVEL1 = 2; | ||
| } | ||
| } | ||
|
|
||
| Summary | ||
| -------- | ||
| Here a small summary for the naming conventions: | ||
|
|
||
| Messages: camel case | ||
|
|
||
| Message Fields: snake case | ||
|
|
||
| Enum: camel case | ||
|
|
||
| Enum Fields: upper case, name of enum converted in upper case snake case and then following the specified name | ||
|
|
||
| After defining the messages do not forget to comment them. See also the `section for commenting <https://opensimulationinterface.github.io/osi-documentation/open-simulation-interface/doc/commenting.html>`_ of fields and messages. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.