# Contributing

This file covers installation from source and the development workflow for contributing [wittrans](https://codeberg.org/artnay/wittrans).

- [Contributing](#contributing)
   * [Reporting Issues](#reporting-issues)
   * [Contributing Code](#contributing-code)
   * [Development](#development)
      + [Prerequisites](#prerequisites)
      + [Clone Repository](#clone-repository)
      + [Running wittrans using uv](#running-wittrans-using-uv)
      + [Installing from Source](#installing-from-source)
      + [Using Make targets](#using-make-targets)
      + [Install Development Dependencies](#install-development-dependencies)
      + [Testing with pytest](#testing-with-pytest)
      + [Code Quality](#code-quality)
         - [Type Checking](#type-checking)
         - [Linting](#linting)
         - [Formatting](#formatting)
      + [Building Package](#building-package)
      + [Development Workflow](#development-workflow)

## Reporting Issues

Report bugs, feature requests, or other issues to Codeberg [issue tracking system](https://codeberg.org/artnay/wittrans/issues).

## Contributing Code

Contributions of all kinds are welcome: bug fixes, new features, and more.

When contributing to this repository, please first discuss the change you wish to make via issue,
email, or any other method with the owner of this repository before making a change.

## Development

This section covers installation from source and the development workflow for contributing.

### Prerequisites

- git >= 2.51.0 (for version control and cloning the repository)
- GNU Make >= 4.0 (for running automated tasks)
- pre-commit >= 4.2.0 (for running git commit checks)
- uv >= 0.8.11 (for workflow and development)

### Clone Repository

Fetch the repository and enter it.

```bash
git clone https://codeberg.org/artnay/wittrans.git && cd wittrans
```

### Running wittrans using uv

You can run wittrans directly from the source code without installing it.

Run wittrans using uv:
```bash
uv run wittrans.py
```

### Using Make Targets

The included Makefile contains several useful commands for development.

Show all available commands (make targets):

```bash
make help
```

### Install Development Dependencies

Install development dependencies using uv and set up pre-commit hooks:

```bash
make dev-install
```

### Testing with pytest

Pytest is used for unit testing. Please add tests for new features to ensure coverage.

Run all tests:

```bash
make test
```

### Code Quality

#### Type Checking

ty is used for type checking the code.

Run type check using ty:

```bash
make typecheck
```

#### Linting

Ruff is used for code linting. Check code for style issues.

Check code for issues using ruff:

```bash
make check
```

Lint code using ruff:

```bash
make lint
```

#### Formatting

Code formatting is handled by Ruff's formatter.

Format code using ruff:

```bash
make format
```

### Building Package

Build distributable packages (wheel and source distribution):

```bash
make build
```

This creates packages in the dist/ directory.

Install the built package locally for testing:

```bash
make install-local
```

Uninstall the locally installed package:

```bash
make uninstall
```

### Development Workflow

1. Clone the repository
2. Install development dependencies with `make dev-install`
3. Make your changes
4. Test your changes with the built package (`make install-local`) before submitting a pull request
5. Ensure everything works by running `make all`
6. Commit your changes (pre-commit hooks should verify code quality)
7. Push your branch and create a pull request.
