godotengine / godotengine/godot-docs

Document C++ code style and naming conventions

Open
#4,685 1 comment 3 reactions 0 assignees View on GitHub
area:engine details enhancement
Dominant language
reStructuredText
Stars
5.7k
Forks
3.8k
Avg merge
1d 20h
Merged PRs (30d)
25

Description

**Your Godot version:**
Any.

**Issue description:**
There's little information regarding existing code style used throughout Godot's C++ codebase in the docs, unlike GDScript and C#. This is important to document to ensure Godot follows consistent code style, and especially important for new contributors.

See godotengine/godot#33027 for consensus regarding C++ code style in Godot. To summarize:

## Formatting
- No empty line after opening brace (enforced by `clang-format`).
- One line between function implementations (no tools found yet).
- Use braces on single-statement if / else blocks (might be doable with `clang-tidy`).
- No short case labels on a single line (can be enforced by `clang-format`).
- Switch/case use of brackets (undecided).

## Code style
- `snake_case` for identifiers (variables).
- `PascalCase` for classes.
- `SHOUTING_SNAKE_CASE` for constants.
- Use `p_` for method parameters, and `r_` for parameters which are intended to "return" something (modified by the method).
- Naming of boolean setters/getters (no consensus yet, see godotengine/godot#33026).

**URL to the documentation page (if already existing):**
Can be added to the ["Code style guidelines"](https://docs.godotengine.org/en/latest/community/contributing/code_style_guidelines.html) page.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.