-
Notifications
You must be signed in to change notification settings - Fork 36
Conventions #100
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
base: master
Are you sure you want to change the base?
Conventions #100
Conversation
fixing typo
fixing typo
…d some more fixes
…onventions. and some more fixes
stand the example to the new conventions electronstudio#88
…ome more changes to other files
61ee4cf
to
3b01e59
Compare
|
||
init_window(screenWidth, screenHeight, "raylib [core] example - 2d camera") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2D
Some other conventions to follow: | ||
- **ALWAYS** initialize all defined variables. | ||
- **use TABS / 4 spaces**. | ||
- Avoid trailing spaces, please, avoid them | ||
- Avoid using **semicolon** as you can |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are linters and formatters for that. ruff
, black
and isort
will be enough to not bothering with those rules.
- **use TABS / 4 spaces**. | ||
- Avoid trailing spaces, please, avoid them | ||
- Avoid using **semicolon** as you can | ||
- Control flow statements always are followed **by a space**: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is strange one, never saw that rule neither on production nor in open source projects. Why?
PEP8 says something like "don't write if-statements in one line"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair
- Avoid using **semicolon** as you can | ||
- Control flow statements always are followed **by a space**: | ||
```python | ||
if condition : value = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have if-expressions for that.
value = 0 if condition else value
Or if it is initialization thing:
value = value or 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That isn't an "if statement" that is the ternary operator
|
||
for i in range(NUM_VALUES): print(i) | ||
``` | ||
- All conditions checks are **always between parenthesis** but not boolean values: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay that's big whaat.
- Why always?
- Why booleans are different?
50 and True will return 50. Should it be between parenthesis?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, as you see the conventions haven't really been reviewed by electrostudio so yeah they aren't perfect, feel free to fork my doing and implementing your conventions
p.s. and yeah the conventions aren't perfect because in the beginning they were made to mimic the raylib code style conventions but maybe following PEP 8 would be better...
568da0c
to
22af403
Compare
hi @electronstudio.
sorry for not pushing the conventions branch. I just forgot to work on it...
currently, I didn't refactor all the examples, but as I can see it, I will probably not work on them anymore. I don't have as much free time as I had in past...