|
| 1 | +## Overview |
| 2 | + |
| 3 | +<p class="intro" markdown> |
| 4 | + |
| 5 | + You will need to set up a Python environment to develop ReactPy-Django. |
| 6 | + |
| 7 | +</p> |
| 8 | + |
| 9 | +!!! abstract "Note" |
| 10 | + |
| 11 | + Looking to contribute features that are not Django specific? |
| 12 | + |
| 13 | + Everything within the `reactpy-django` repository must be specific to Django integration. Check out the [ReactPy Core documentation](https://reactpy.dev/docs/about/contributor-guide.html) to contribute general features such as components, hooks, and events. |
| 14 | + |
| 15 | +--- |
| 16 | + |
| 17 | +## Creating a development environment |
| 18 | + |
| 19 | +If you plan to make code changes to this repository, you will need to install the following dependencies first: |
| 20 | + |
| 21 | +- [Git](https://git-scm.com/downloads) |
| 22 | +- [Python 3.9+](https://www.python.org/downloads/) |
| 23 | +- [Hatch](https://hatch.pypa.io/latest/) |
| 24 | +- [Bun](https://bun.sh/) |
| 25 | + |
| 26 | +Once you finish installing these dependencies, you can clone this repository: |
| 27 | + |
| 28 | +```bash linenums="0" |
| 29 | +git clone https://github.com/reactive-python/reactpy-django.git |
| 30 | +cd reactpy-django |
| 31 | +``` |
| 32 | + |
| 33 | +## Executing test environment commands |
| 34 | + |
| 35 | +By utilizing `hatch`, the following commands are available to manage the development environment. |
| 36 | + |
| 37 | +### Tests |
| 38 | + |
| 39 | +| Command | Description | |
| 40 | +| --- | --- | |
| 41 | +| `hatch test` | Run Python tests using the current environment's Python version | |
| 42 | +| `hatch test --all` | Run tests using all compatible Python versions | |
| 43 | +| `hatch test --python 3.9` | Run tests using a specific Python version | |
| 44 | +| `hatch test --include "django=5.1"` | Run tests using a specific Django version | |
| 45 | +| `hatch test -k test_object_in_templatetag` | Run only a specific test | |
| 46 | +| `hatch test --ds test_app.settings_multi_db` | Run tests with a specific Django settings file | |
| 47 | +| `hatch run django:runserver` | Manually run the Django development server without running tests | |
| 48 | + |
| 49 | +??? question "What other arguments are available to me?" |
| 50 | + |
| 51 | + The `hatch test` command is a wrapper for `pytest`. Hatch "intercepts" a handful of arguments, which can be previewed by typing `hatch test --help`. |
| 52 | + |
| 53 | + Any additional arguments in the `test` command are directly passed on to pytest. See the [pytest documentation](https://docs.pytest.org/en/stable/reference/reference.html#command-line-flags) for what additional arguments are available. |
| 54 | + |
| 55 | +### Linting and Formatting |
| 56 | + |
| 57 | +| Command | Description | |
| 58 | +| --- | --- | |
| 59 | +| `hatch fmt` | Run all linters and formatters | |
| 60 | +| `hatch fmt --check` | Run all linters and formatters, but do not save fixes to the disk | |
| 61 | +| `hatch fmt --linter` | Run only linters | |
| 62 | +| `hatch fmt --formatter` | Run only formatters | |
| 63 | +| `hatch run javascript:check` | Run the JavaScript linter/formatter | |
| 64 | +| `hatch run javascript:fix` | Run the JavaScript linter/formatter and write fixes to disk | |
| 65 | + |
| 66 | +??? tip "Configure your IDE for linting" |
| 67 | + |
| 68 | + This repository uses `hatch fmt` for linting and formatting, which is a [modestly customized](https://hatch.pypa.io/latest/config/internal/static-analysis/#default-settings) version of [`ruff`](https://github.com/astral-sh/ruff). |
| 69 | + |
| 70 | + You can install `ruff` as a plugin to your preferred code editor to create a similar environment. |
| 71 | + |
| 72 | +### Documentation |
| 73 | + |
| 74 | +| Command | Description | |
| 75 | +| --- | --- | |
| 76 | +| `hatch run docs:serve` | Start the [`mkdocs`](https://www.mkdocs.org/) server to view documentation locally | |
| 77 | +| `hatch run docs:build` | Build the documentation | |
| 78 | +| `hatch run docs:linkcheck` | Check for broken links in the documentation | |
| 79 | +| `hatch run docs:check_examples` | Run linter on code examples in the documentation | |
| 80 | + |
| 81 | +### Environment Management |
| 82 | + |
| 83 | +| Command | Description | |
| 84 | +| --- | --- | |
| 85 | +| `hatch build --clean` | Build the package from source | |
| 86 | +| `hatch env prune` | Delete all virtual environments created by `hatch` | |
| 87 | +| `hatch python install 3.12` | Install a specific Python version to your system | |
| 88 | + |
| 89 | +??? tip "Check out Hatch for all available commands!" |
| 90 | + |
| 91 | + This documentation only covers commonly used commands. |
| 92 | + |
| 93 | + You can type `hatch --help` to see all available commands. |
0 commit comments