From 802e97ee695de1bc8657c5cbca653bb2f13b90a8 Mon Sep 17 00:00:00 2001 From: skal Date: Mon, 9 Feb 2026 15:35:14 +0100 Subject: docs: Condense essential context files (856→599 lines) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extract detailed examples and untriaged tasks to on-demand docs. Created BACKLOG.md, ARCHITECTURE.md, CODING_STYLE.md, TOOLS_REFERENCE.md. Reduces always-loaded token budget by 30% while preserving all information. Co-Authored-By: Claude Sonnet 4.5 --- doc/CODING_STYLE.md | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 doc/CODING_STYLE.md (limited to 'doc/CODING_STYLE.md') diff --git a/doc/CODING_STYLE.md b/doc/CODING_STYLE.md new file mode 100644 index 0000000..533cffb --- /dev/null +++ b/doc/CODING_STYLE.md @@ -0,0 +1,109 @@ +# Coding Style Examples + +Detailed examples for the project's C++ coding style. + +--- + +## Core Rules Examples + +### Const Placement +```cpp +const T* name // Correct +const T *name // Wrong +``` + +### Pre-Increment +```cpp +++x // Correct +x++ // Wrong (except when postfix needed) +``` + +### Operator Spacing +```cpp +x = (a + b) * c; // Correct - spaces around all operators +x=(a+b)*c; // Wrong - no spaces +``` + +### No Auto (except complex iterators) +```cpp +int count = get_count(); // Correct +auto count = get_count(); // Wrong + +for (auto it = map.begin(); ...) // OK - complex iterator type +``` + +### No C++ Casts +```cpp +(int)value // Correct +static_cast(value) // Wrong +``` + +--- + +## Preprocessor Style + +```cpp +#if defined(MY_TAG) + // code here +#endif /* defined(MY_TAG) */ +``` + +Always use `defined()` and closing comment. + +--- + +## Struct Initialization + +### Good +```cpp +const WGPUDescriptor desc = { + .format = g_format, + .dimension = WGPUTextureViewDimension_2D, +}; +``` + +### Bad +```cpp +WGPUDescriptor desc = {}; +desc.format = g_format; +desc.dimension = WGPUTextureViewDimension_2D; +``` + +Use designated initializers, not field-by-field assignment. + +--- + +## Class Keywords Indentation + +```cpp +class MyClass { + public: // 1 space indent + void foo(); + + private: // 1 space indent + int field_; +}; +``` + +--- + +## Comments + +### Function Comments +```cpp +// Initializes the audio engine with default settings. +void audio_init() { + ... +} +``` + +One-line comment for non-obvious functions. + +### File Headers +```cpp +// demo64k - 64 kilobyte demo +// src/audio/synth.cc +// Audio synthesis engine +``` + +Three-line header for all source files. -- cgit v1.2.3