Skip to content

Commit ac94bb3

Browse files
committed
Updated README
1 parent 1f948c7 commit ac94bb3

38 files changed

Lines changed: 5336 additions & 2176 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ venv.bak/
139139

140140
# mkdocs documentation
141141
/site
142+
documentation/site/
142143

143144
# mypy
144145
.mypy_cache/

CLAUDE.md

Lines changed: 0 additions & 170 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
# Contributing to StxScript
2+
3+
Thank you for your interest in contributing to StxScript. This document provides guidelines and information for contributors.
4+
5+
## Code of Conduct
6+
7+
This project adheres to the [Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.
8+
9+
## Getting Started
10+
11+
### Prerequisites
12+
13+
- Python 3.10+
14+
- [uv](https://docs.astral.sh/uv/) (recommended) or pip
15+
- Git
16+
17+
### Development Setup
18+
19+
```bash
20+
git clone https://github.com/cryptuon/stxscript.git
21+
cd stxscript
22+
uv venv && uv pip install -e ".[dev]"
23+
```
24+
25+
### Running Tests
26+
27+
```bash
28+
# All tests (146 tests)
29+
uv run python -m pytest tests/
30+
31+
# With coverage
32+
uv run python -m pytest tests/ --cov=stxscript
33+
34+
# Specific test file
35+
uv run python -m pytest tests/test_transpiler.py -v
36+
```
37+
38+
### Code Quality
39+
40+
```bash
41+
uv run black stxscript/ # Format
42+
uv run flake8 stxscript/ # Lint
43+
uv run mypy stxscript/ # Type check
44+
```
45+
46+
## How to Contribute
47+
48+
### Reporting Bugs
49+
50+
Open an issue with:
51+
52+
- Clear description of the problem
53+
- Steps to reproduce
54+
- Expected vs actual behavior
55+
- StxScript version (`stxscript --version`)
56+
- Python version and OS
57+
58+
### Suggesting Features
59+
60+
Open an issue with:
61+
62+
- Description of the feature
63+
- Use case and motivation
64+
- Example of how it would work (StxScript input and expected Clarity output)
65+
66+
### Submitting Changes
67+
68+
1. Fork the repository
69+
2. Create a feature branch: `git checkout -b feature/my-feature`
70+
3. Make your changes
71+
4. Add or update tests
72+
5. Ensure all tests pass: `uv run python -m pytest tests/`
73+
6. Ensure code is formatted: `uv run black stxscript/`
74+
7. Commit with a clear message
75+
8. Push and open a pull request
76+
77+
### Commit Messages
78+
79+
Use conventional commit format:
80+
81+
```
82+
<type>: <description>
83+
84+
[optional body]
85+
```
86+
87+
Types:
88+
- `feat` - New feature
89+
- `fix` - Bug fix
90+
- `docs` - Documentation changes
91+
- `test` - Adding or updating tests
92+
- `refactor` - Code refactoring
93+
- `style` - Code style/formatting
94+
- `chore` - Maintenance tasks
95+
96+
Examples:
97+
```
98+
feat: add buffer size validation to type checker
99+
fix: correct kebab-case conversion for multi-word identifiers
100+
docs: update CLI reference with new pkg commands
101+
test: add property-based tests for expression parsing
102+
```
103+
104+
## Development Guide
105+
106+
### Project Structure
107+
108+
```
109+
stxscript/
110+
├── stxscript/ # Main package
111+
│ ├── transpiler.py # Transpilation orchestrator
112+
│ ├── working_grammar.lark # Production grammar (Lark LALR)
113+
│ ├── ast_nodes.py # AST node definitions
114+
│ ├── ast_builder.py # Parse tree → AST transformer
115+
│ ├── semantic_analyzer.py # Type checking and validation
116+
│ ├── clarity_generator.py # AST → Clarity code generation
117+
│ ├── error_handler.py # Error reporting with suggestions
118+
│ ├── cli.py # CLI with subcommands
119+
│ ├── formatter.py # Code formatter
120+
│ ├── linter.py # Static analysis
121+
│ ├── lsp_server.py # Language Server Protocol
122+
│ ├── testing.py # Contract testing framework
123+
│ └── package_manager.py # Dependency management
124+
├── tests/ # Test suite
125+
├── documentation/ # User-facing docs (mkdocs)
126+
└── vscode-extension/ # VS Code extension
127+
```
128+
129+
### Adding a Language Feature
130+
131+
1. **Grammar**: Add rules to `stxscript/working_grammar.lark`
132+
2. **AST Nodes**: Define nodes in `stxscript/ast_nodes.py`
133+
3. **AST Builder**: Add transformer methods in `stxscript/ast_builder.py`
134+
4. **Semantic Analysis**: Add checks in `stxscript/semantic_analyzer.py`
135+
5. **Code Generation**: Add generation in `stxscript/clarity_generator.py`
136+
6. **Tests**: Add test cases in `tests/`
137+
138+
### Testing Guidelines
139+
140+
- Test both successful transpilation and error cases
141+
- Include the expected Clarity output in assertions
142+
- Use descriptive test method names: `test_for_loop_range_extraction`
143+
- Add property-based tests for parser robustness when appropriate
144+
145+
```python
146+
import unittest
147+
from stxscript import StxScriptTranspiler
148+
149+
class TestNewFeature(unittest.TestCase):
150+
def setUp(self):
151+
self.transpiler = StxScriptTranspiler()
152+
153+
def test_feature_produces_correct_clarity(self):
154+
stx_code = 'let x: uint = 42u;'
155+
result = self.transpiler.transpile(stx_code)
156+
self.assertIn('(define-data-var x uint u42)', result)
157+
```
158+
159+
### Code Style
160+
161+
- Follow PEP 8
162+
- Use type hints for function signatures
163+
- Use Black for formatting (line length 100)
164+
- Keep functions focused and testable
165+
166+
## Pull Request Checklist
167+
168+
Before submitting:
169+
170+
- [ ] Tests pass: `uv run python -m pytest tests/`
171+
- [ ] Code formatted: `uv run black stxscript/`
172+
- [ ] Linting passes: `uv run flake8 stxscript/`
173+
- [ ] New tests added for new functionality
174+
- [ ] Documentation updated if applicable
175+
- [ ] Commit messages follow conventional format
176+
177+
## License
178+
179+
By contributing to StxScript, you agree that your contributions will be licensed under the [MIT License](LICENSE).

0 commit comments

Comments
 (0)