Skip to content

Commit 5178af8

Browse files
committed
Add docs for new hatch commands
1 parent 3aac221 commit 5178af8

File tree

6 files changed

+126
-141
lines changed

6 files changed

+126
-141
lines changed

docs/mkdocs.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ nav:
1616
- Management Commands: reference/management-commands.md
1717
- About:
1818
- Changelog: about/changelog.md
19-
- Contributor Guide:
20-
- Code: about/code.md
21-
- Docs: about/docs.md
19+
- Contributor Guide: about/contributing.md
2220
- Community:
2321
- GitHub Discussions: https://github.com/reactive-python/reactpy-django/discussions
2422
- Discord: https://discord.gg/uNb5P4hA9X

docs/src/about/code.md

-85
This file was deleted.

docs/src/about/contributing.md

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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.

docs/src/about/docs.md

-45
This file was deleted.

docs/src/dictionary.txt

+5
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,8 @@ unstyled
4343
WebSocket
4444
WebSockets
4545
whitespace
46+
pytest
47+
linter
48+
linters
49+
linting
50+
formatters

pyproject.toml

+27-8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
build-backend = "hatchling.build"
33
requires = ["hatchling", "hatch-build-scripts"]
44

5+
##############################
6+
# >>> Hatch Build Config <<< #
7+
##############################
8+
59
[project]
610
name = "reactpy_django"
711
description = "It's React, but in Python. Now with Django integration."
@@ -43,7 +47,7 @@ dependencies = [
4347
"reactpy>=1.0.0, <2.0.0",
4448
"reactpy-router>=1.0.0, <2.0.0",
4549
"dill>=0.3.5",
46-
"orjson >=3.6.0",
50+
"orjson>=3.6.0",
4751
"nest_asyncio>=1.5.0",
4852
"typing_extensions",
4953
]
@@ -77,7 +81,10 @@ commands = [
7781
]
7882
artifacts = []
7983

80-
# >>> Hatch Test Suite <<<
84+
#############################
85+
# >>> Hatch Test Runner <<< #
86+
#############################
87+
8188
[tool.hatch.envs.hatch-test]
8289
extra-dependencies = [
8390
"pytest-sugar",
@@ -128,18 +135,23 @@ django_find_project = false
128135
DJANGO_SETTINGS_MODULE = "test_app.settings_single_db"
129136
pythonpath = [".", "tests/"]
130137

138+
################################
139+
# >>> Hatch Django Scripts <<< #
140+
################################
131141

132-
# >>> Hatch Django Scripts <<<
133142
[tool.hatch.envs.django]
134143
extra-dependencies = ["channels[daphne]>=4.0.0", "twisted", "servestatic"]
135144

136145
[tool.hatch.envs.django.scripts]
137146
runserver = [
138-
"cd tests && python manage.py migrate --noinput && python manage.py runserver",
147+
"cd tests && python manage.py migrate --noinput",
148+
"cd tests && python manage.py runserver",
139149
]
140150

151+
#######################################
152+
# >>> Hatch Documentation Scripts <<< #
153+
#######################################
141154

142-
# >>> Hatch Documentation Scripts <<<
143155
[tool.hatch.envs.docs]
144156
template = "docs"
145157
extra-dependencies = [
@@ -168,14 +180,21 @@ deploy_latest = ["cd docs && mike deploy --push --update-aliases {args} latest"]
168180
deploy_develop = ["cd docs && mike deploy --push develop"]
169181
check_examples = ["ruff check docs/examples/python"]
170182

171-
# >>> Hatch JS Scripts <<<
183+
############################
184+
# >>> Hatch JS Scripts <<< #
185+
############################
186+
172187
[tool.hatch.envs.javascript]
173188
detached = true
174189

175190
[tool.hatch.envs.javascript.scripts]
176-
check = ["cd src/js && bun install && bun run check"]
191+
check = ["cd src/js && bun install", "cd src/js && bun run check"]
192+
fix = ["cd src/js && bun install", "cd src/js && bun run check --write"]
193+
194+
#########################
195+
# >>> Generic Tools <<< #
196+
#########################
177197

178-
# >>> Generic Tools <<<
179198
[tool.ruff]
180199
extend-exclude = ["*/migrations/*", ".venv/*", ".eggs/*", ".nox/*", "build/*"]
181200
line-length = 120

0 commit comments

Comments
 (0)