Contributing¶
Contributions are welcome! This document outlines how to contribute to nim-debra.
Development Setup¶
-
Clone the repository:
-
Install dependencies:
-
Run tests:
Testing¶
All changes should include tests. The test suite is located in tests/:
- Unit tests for individual typestates in
tests/t_*.nim - Integration tests in
tests/t_integration.nim - Main test runner in
tests/test.nim
Run tests with:
Code Style¶
- Follow standard Nim style conventions
- Use meaningful variable and function names
- Add documentation comments for public APIs
- Keep functions focused and single-purpose
Typestate Design¶
When adding or modifying typestates:
- Define states as
distincttypes wrapping a context object - Use
typestateblock to declare valid transitions - Mark transition functions with
{.transition.}pragma - Write tests that verify both valid and invalid transitions
Example:
type
Context = object
data: int
StateA = distinct Context
StateB = distinct Context
typestate Context:
states StateA, StateB
transitions:
StateA -> StateB
proc transition(a: StateA): StateB {.transition.} =
StateB(a.Context)
Documentation¶
- Add docstrings to all public procs and types
- Update relevant guide pages in
docs/guide/ - Run
mkdocs serveto preview documentation locally
Pull Requests¶
- Create a feature branch from
main - Make your changes with clear commit messages
- Add tests for new functionality
- Update documentation as needed
- Submit a pull request
Questions?¶
Open an issue on GitHub or start a discussion.