Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions CODE-OF-CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Pill Project Code of Conduct

## 1. Be Respectful
Treat all contributors with respect. Differences in experience, background, and perspective are welcome.

## 2. Be Constructive
Provide helpful feedback. Critique code, not people. Keep discussions focused on improving the project.

## 3. Be Inclusive
Everyone is welcome to participate. Harassment, discrimination, or exclusionary behavior is not tolerated.

## 4. Collaborate Openly
Use public channels for project-related communication when possible. Share knowledge to help others grow.

## 5. Follow Project Standards
Stick to the project’s coding style, guidelines, and review process. Strive for clarity, safety, and maintainability.

## 6. Report Issues Responsibly
If you encounter unacceptable behavior, report it via GitHub issues or direct contact with the maintainer.

## 7. Maintain a Positive Community
This project exists to learn, build, and have fun. Help keep it welcoming and friendly.

## 8. Create Memes

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😆

We all love memes, especially those related to the projects we work on :3
74 changes: 74 additions & 0 deletions CODING-STANDARDS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Pill Project Coding Standards

This document defines coding standards for the Pill project, ensuring consistency, readability, maintainability, and idiomatic language practices.

## 1. General Principles
1. Prioritize safety, clarity, and performance.
2. Prefer idiomatic Rust patterns and avoid unnecessary abstractions.
3. Favor expressiveness without sacrificing simplicity.
4. Always import types, functions and macros explicitly at the top of the file (e.g. `use anyhow::Result;`).

## 2. Naming Conventions
1. Types (structs, enums, traits): PascalCase.
2. Functions, variables, modules, resources (texture, sound, model files), shader/material parameters: snake_case.
3. Constants and statics: SCREAMING_SNAKE_CASE.
4. Generics: short uppercase letters (`T`, `E`, `R`), descriptive when needed (Request, Response).
5. Use fully descriptive, expressive names rather than abbreviations — clarity is more important than brevity.
6. Avoid abbreviations such as `env`, `dt`, `tex`, `ctx`, `fmt`, `rot`, `pos`, or similar. The only allowed exceptions are the Rust keywords like `mut`, `ref`, `ptr`, `len`, `idx`, and `dyn`.
Comment thread
MattSzymonski marked this conversation as resolved.
7. Using long names is encouraged as they make intent clearer.

## 3. Project Structure
1. Organize modules using clear directory hierarchies.
2. Keep files small and cohesive.
3. Name crates and modules using snake_case.
4. Place universal, shared, or cross-cutting utilities in the pill_core module to keep functionality centralized and avoid duplication.
5. Each folder must contain a mod.rs file to clearly define the module's public API and re-export relevant items.

## 4. Error handling
1. Use `Result<T, E>` for recoverable errors.
2. In binary crates, prefer `anyhow::Result` and attach context using `.context("...")?` for clearer diagnostics.
3. Use the `?` operator extensively for propagating errors.
4. Avoid panics except for unrecoverable logic errors.
Comment thread
MattSzymonski marked this conversation as resolved.

## 5. Code Style
1. Follow rustfmt code formatter for formatting.
2. Follow clippy code linter recommendations unless deviating intentionally; document deviations.
3. Break long expressions using intermediate variables for readability.
4. Keep function bodies short and single-responsibility.

## 6. Documentation
1. Important game-developer–facing areas (materials, audio, ECS basics API, etc.) must each have a dedicated page in the Pill Guide.
2. Engine subsystems and internal architecture must be documented in the Engine Internals section of the Pill Guide
3. Every public function, type, and module must have a `///` doc comment (so it appears correctly in cargo doc) that well explains the purpose of the function
Comment thread
MattSzymonski marked this conversation as resolved.
4. Public APIs functions should include short, runnable examples to clarify usage.
5. Documentation must be updated whenever related code changes to avoid drift.

## 7. Testing
1. Write unit tests for all critical logic, especially pure functions and data transformations.
Comment thread
MattSzymonski marked this conversation as resolved.
2. Write unit tests directly under the code they validate, in the same module.
3. Avoid complex test setups; extract helpers if needed.
4. Avoid testing implementation details. Focus on observable behavior and invariants.
Comment thread
MattSzymonski marked this conversation as resolved.
5. Document test purpose clearly with a `///` doc comment so failures provide meaningful insight.

## 8. Unsafe Code Guidelines
1. Avoid unsafe unless necessary for performance or FFI.
2. Encapsulate unsafe blocks behind safe abstractions.
3. Document why unsafe is required and the invariants it relies on.

## 9. Logging & Observability
1. Use the contextual logging macros (`info!(ctx => ...)`, etc.) with a required `LogContext`, unless intentionally using "default".
2. Configure logging per context using strings like ecs = debug and follow consistent log-level semantics.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unclear to me - what do you mean by ecs = debug?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, there is extremaly useful configurable logging system implemented in the engine but not documented anywhere properly. This line refers to it. I will document it.

3. Keep log messages clear and descriptive, avoiding abbreviations.
4. Use the project's Timer utility when measuring execution time for functions, subsystems, or critical paths.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
4. Use the project's Timer utility when measuring execution time for functions, subsystems, or critical paths.
4. Use the project's `Timer` utility when measuring execution time for functions, subsystems, or critical paths.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, timer system has to be documented

5. Structure timing output with nested contexts (`begin_context` / `end_context`) to maintain readable, hierarchical performance data.

## 10. Code Review Expectations
Comment thread
MattSzymonski marked this conversation as resolved.
1. Ensure PRs are small and focused.
2. Submitted code should not trigger any warnings.
2. Request feedback early for architectural changes.
3. Review for correctness, clarity, and idiomatic usage.
Comment thread
MattSzymonski marked this conversation as resolved.

## 11. Version Control

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I would also be more specific - should we follow kernel guidelines? Use conventional commits? I would be for the latter as we enter a stage of bigger maturity of the project and once it is very mature it would make the commit bisection/triage easier when the commits are more self-descriptive.
Also what is our policy regarding commit squashing and merging/rebasing?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you propose something? I'm not that experienced in this

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion conventional commits are easy enough because one can see which part of the engine we are touching. Ideally it follows the folder/project structure. The website describes it quite nicely:

  • feat for a new feature
  • fix for a bugfix
  • BREAKING CHANGE or prepending the commit name with ! (although I would use something else here as ! is easy to ommit.
  • I used others in past like docs or infra to specify either documentation or infrastructure (in this case toolchain/core compilator/libs changes) we could also use ci
    Lastly I would expect to have, for example, such commits feat(zapping): Add zapping system that periodically flabbergast doodahs. Or we could do it by splitting per-system or subproject - but IMO that is too coarse-grained.

What do you think?

1. Use descriptive commit messages.
2. Try to keep commits atomic.
3. Avoid committing generated files.