Skip to content

Contribution Guide

Cursor Agent edited this page Nov 29, 2026 · 4 revisions

Contribution Guide

Thanks for working on Fanalor. The rules below are the ones main is held to. The full naming and layout note is docs/CONVENTIONS.md. The engine's design decisions live in docs/ARCHITECTURE.md.

Branches

Branch off main. Do not commit directly to main.

Prefix Use
feature/<topic> New behaviour
fix/<topic> A bug
refactor/<topic> A restructure that does not change behaviour
docs/<topic> Documentation only

Open a pull request into main.

Commits

Conventional Commits. The scope is the crate without the fanalor- prefix. The subject is imperative, has no trailing period, and is at most 50 characters. A body is for the why, when the diff does not show it.

feat(render): add render pipeline and WGSL shader loading
fix(core): skip redraw while the window is minimised
docs(architecture): record wgpu 30 API differences

Types in use: feat, fix, docs, refactor, perf, test, chore.

Code

Naming follows RFC 430 and the Rust API Guidelines.

Item Case Example
Package kebab-case fanalor-render
Directory under crates/ the same string crates/fanalor-render/
Module, file, function, field snake_case gpu_context.rs
Type, trait, enum variant UpperCamelCase GpuContext
Constant SCREAMING_SNAKE_CASE MAX_FRAMES_IN_FLIGHT
Shader snake_case .wgsl flat_color.wgsl

Acronyms are one word: GpuContext, not GPUContext. The package fanalor-render is imported as fanalor_render. Do not rename the package to match the import. Crate names do not carry a -rs or rust- suffix.

  • The workspace root stays a virtual manifest. No src/ at the root.
  • Every third-party version lives in the root [workspace.dependencies]. Members use dep.workspace = true.
  • winit only in fanalor-core. wgpu only in fanalor-render. cpal and symphonia only in fanalor-audio. tungstenite only in fanalor-net.
  • No third-party ECS, scene-graph, or engine-framework crate. The egui wgpu backend in fanalor-render is ours because the published one is pinned to an older wgpu.
  • One concept per file. Split a module into a directory around 300 lines or when a second concept appears. Prefer foo.rs plus foo/ over foo/mod.rs.
  • Public items have a /// doc comment. Crates set #![warn(missing_docs)], and clippy denies warnings, so a missing comment fails the build.
  • No unwrap() outside tests. expect("why this cannot fail") when the invariant is real.
  • Log through the log crate. See Logging.
  • Handle the empty, resized, and despawned cases in the same change. Do not fail silently.
  • The engine is 2D. Do not add a depth buffer, a 3D transform, or an unused axis "for later". Sorting is sort_order and sorting layers.

GPU, editor UI, and audio code should be checked against the vendored crate sources or current docs before it is written. wgpu 30, winit 0.30, egui 0.35, cpal 0.18, and symphonia 0.6 do not match older tutorials. Lasting findings go into docs/ARCHITECTURE.md.

Before a pull request

cargo fmt --all
cargo clippy --workspace --all-targets -- -D warnings
cargo test --workspace

Scope clippy and tests to the crates you touched while iterating. Run the workspace before the PR if the change is on a shared surface. A warning that is genuinely a false positive gets an #[allow(...)] on that item with a comment, not a crate-wide allow.

If the change is on a hot path, compare benchmarks. See Testing Guide.

cargo xtask bench --runs 3 --compare target/bench/base.json

If the change is user-facing, update the matching chapter under docs/guide/ and run cargo xtask guide. The guide's <!-- ci --> blocks are the commands CI will run.

The pull request template asks for a summary, the public types and file formats that moved, the design and any prior art (Unity, Unreal, Godot, Bevy) you adopted or rejected, and how you verified it. Delete sections that do not apply.

Reviews

  • Fork, branch from current main, and open the PR against main.
  • Describe the behaviour change and point at the tests that pin it.
  • A review that asks for a different shape is about the design in docs/ARCHITECTURE.md, not about taste in isolation. Record a lasting decision there.

Clone this wiki locally