Skip to content

Commit

Permalink
add a document explaining mandatory coding guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
Theverat committed Feb 27, 2020
1 parent 60e917d commit a2645ee
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doc/code_style.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The most important stuff:
* classes use CamelCase (except where Blender needs special class names, e.g. operators)
* methods and functions are lowercase, words separated by underscores: update_objects()
* "private" methods/members start with a leading underscore: _internal_update()
* Property descriptions must never end with a dot.
* Enum identifiers should be valid Python identifiers (don't contain spaces, don't start with a number etc.)

For UI texts (buttons, tooltips, panel names) we follow the Blender guidelines:
https://wiki.blender.org/index.php/Dev:Doc/Code_Style#UI_Messages
Expand Down
27 changes: 27 additions & 0 deletions doc/mandatory.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
The stuff in the code_style.md document should be followed, but it is ultimately just about
the readability of the source code.
The following is really important though. If these guidelines are not followed, it can cause
massive problems - and not just now, but also years in the future.

### Enums

**Always** add an index for each element.
If the index is missing, we can not reorder elements later and we can not rename identifiers
without breaking old .blend files.

Wrong:
```python
items = [
("first_item", "First Item", "This is the first item"),
("second_item", "Second Item", "This is the second item"),
]
```

Correct:
```python
items = [
("first_item", "First Item", "This is the first item", 0),
("second_item", "Second Item", "This is the second item", 1),
]
```
(note the 0 and 1 after the descriptions)

0 comments on commit a2645ee

Please sign in to comment.