Skip to content

Commit 085cebe

Browse files
authored
Docs version control and new theme (#176)
- Version controlled docs - Every time something is committed to `main`, it will update the `develop` docs. - Every time a version is released, it will push a new version number to the docs. - Use our new ReactPy docs theme, which is an even better imitation of ReactJS docs - Fix `GITHUB_ACTIONS` env type conversion
1 parent aae9c7a commit 085cebe

32 files changed

+678
-374
lines changed

Diff for: .github/workflows/publish-develop-docs.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Publish Develop Docs
2+
on:
3+
push:
4+
branches:
5+
- main
6+
jobs:
7+
deploy:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
with:
12+
fetch-depth: 0
13+
- uses: actions/setup-python@v4
14+
with:
15+
python-version: 3.x
16+
- run: pip install -r requirements/build-docs.txt
17+
- name: Publish Develop Docs
18+
run: mike deploy --push develop

Diff for: .github/workflows/publish-docs.yml

-17
This file was deleted.

Diff for: .github/workflows/publish-release-docs.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Publish Release Docs
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
deploy:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
with:
13+
fetch-depth: 0
14+
- uses: actions/setup-python@v4
15+
with:
16+
python-version: 3.x
17+
- run: pip install -r requirements/build-docs.txt
18+
- name: Publish ${{ github.event.release.name }} Docs
19+
run: mike deploy --push --update-aliases ${{ github.event.release.name }} latest

Diff for: CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ Using the following categories, list your changes in this order:
3434

3535
## [Unreleased]
3636

37+
### Added
38+
39+
- [ReactPy-Django docs](https://reactive-python.github.io/reactpy-django/) are now version controlled via [mike](https://github.com/jimporter/mike)!
40+
3741
### Changed
3842

3943
- Bumped the minimum ReactPy version to `1.0.2`.

Diff for: README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
<!--badge-end-->
2424
<!--intro-start-->
2525

26+
[ReactPy-Django](https://github.com/reactive-python/reactpy-django) is used to add used to add [ReactPy](https://reactpy.dev/) support to an existing **Django project**.
27+
2628
[ReactPy](https://reactpy.dev/) is a library for building user interfaces in Python without Javascript. ReactPy interfaces are made from components that look and behave similar to those found in [ReactJS](https://reactjs.org/). Designed with simplicity in mind, ReactPy can be used by those without web development experience while also being powerful enough to grow with your ambitions.
2729

2830
<table align="center">
@@ -77,11 +79,12 @@ def hello_world(recipient: str):
7779

7880
<!--html-header-start-->
7981

80-
In your **Django app**'s HTML template, you can now embed your ReactPy component using the `component` template tag. Within this tag, you will need to type in your dotted path to the component function as the first argument.
81-
82-
Additionally, you can pass in `args` and `kwargs` into your component function. For example, after reading the code below, pay attention to how the function definition for `hello_world` (_in the previous example_) accepts a `recipient` argument.
82+
In your **Django app**'s HTML template, you can now embed your ReactPy component using the `component` template tag. Within this tag, you will need to type in the dotted path to the component.
8383

8484
<!--html-header-end-->
85+
86+
Additionally, you can pass in `args` and `kwargs` into your component function. After reading the code below, pay attention to how the function definition for `hello_world` (_from the previous example_) accepts a `recipient` argument.
87+
8588
<!--html-code-start-->
8689

8790
```jinja

Diff for: docs/overrides/main.html

+7
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,10 @@
1111
</div>
1212
{% endif %}
1313
{% endblock %}
14+
15+
{% block outdated %}
16+
You're not viewing the latest version.
17+
<a href="{{ '../' ~ base_url }}">
18+
<strong>Click here to go to latest.</strong>
19+
</a>
20+
{% endblock %}

Diff for: docs/src/changelog/index.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ hide:
33
- toc
44
---
55

6-
!!! summary "Attribution"
6+
<p class="intro" markdown>
77

8-
{% include-markdown "../../../CHANGELOG.md" start="<!--attr-start-->" end="<!--attr-end-->" %}
8+
{% include-markdown "../../../CHANGELOG.md" start="<!--attr-start-->" end="<!--attr-end-->" %}
9+
10+
</p>
11+
12+
---
913

1014
{% include-markdown "../../../CHANGELOG.md" start="<!--changelog-start-->" %}

Diff for: docs/src/contribute/code.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
## Overview
22

3-
!!! summary "Overview"
3+
<p class="intro" markdown>
44

55
You will need to set up a Python environment to develop ReactPy-Django.
66

7-
??? tip "Looking to contribute features that are not Django specific?"
7+
</p>
88

9-
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, events, and more.
9+
!!! 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+
---
1016

1117
## Modifying Code
1218

Diff for: docs/src/contribute/docs.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
## Overview
22

3-
!!! summary "Overview"
3+
<p class="intro" markdown>
44

5-
You will need to set up a Python environment to preview docs changes.
5+
You will need to set up a Python environment to create, test, and preview docs changes.
6+
7+
</p>
8+
9+
---
610

711
## Modifying Docs
812

Diff for: docs/src/contribute/running-tests.md

+19-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
## Overview
22

3-
!!! summary "Overview"
3+
<p class="intro" markdown>
44

5-
You will need to set up a Python environment to run out test suite.
5+
You will need to set up a Python environment to run the ReactPy-Django test suite.
6+
7+
</p>
8+
9+
---
610

711
## Running Tests
812

@@ -29,17 +33,26 @@ By running the command below you can run the full test suite:
2933
nox -s test
3034
```
3135

32-
Or, if you want to run the tests in the foreground:
36+
Or, if you want to run the tests in the background:
3337

3438
```bash linenums="0"
35-
nox -s test -- --headed
39+
nox -s test -- --headless
3640
```
3741

38-
## Only Django Tests
42+
## Django Tests
3943

40-
Alternatively, if you want to only run Django related tests, you can use the following command:
44+
If you want to only run our Django tests in your current environment, you can use the following command:
4145

4246
```bash linenums="0"
4347
cd tests
4448
python manage.py test
4549
```
50+
51+
## Django Test Webserver
52+
53+
If you want to manually run the Django test application, you can use the following command:
54+
55+
```bash linenums="0"
56+
cd tests
57+
python manage.py runserver
58+
```

Diff for: docs/src/features/components.md

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
## Overview
22

3-
!!! summary "Overview"
3+
<p class="intro" markdown>
44

5-
Prefabricated components can be used within your `components.py` to help simplify development.
5+
We supply some pre-designed that components can be used to help simplify development.
6+
7+
</p>
8+
9+
---
610

711
## View To Component
812

@@ -29,7 +33,7 @@ Convert any Django view into a ReactPy component by using this decorator. Compat
2933

3034
| Type | Description |
3135
| --- | --- |
32-
| `_ViewComponentConstructor` | A function that takes `request, *args, key, **kwargs` and returns an ReactPy component. All parameters are directly provided to your view, besides `key` which is used by ReactPy. |
36+
| `_ViewComponentConstructor` | A function that takes `request, *args, key, **kwargs` and returns a ReactPy component. All parameters are directly provided to your view, besides `key` which is used by ReactPy. |
3337

3438
??? Warning "Potential information exposure when using `compatibility = True`"
3539

@@ -180,7 +184,7 @@ Allows you to defer loading a CSS stylesheet until a component begins rendering.
180184

181185
| Type | Description |
182186
| --- | --- |
183-
| `Component` | An ReactPy component. |
187+
| `Component` | A ReactPy component. |
184188

185189
??? question "Should I put `django_css` at the top of my HTML?"
186190

@@ -235,7 +239,7 @@ Allows you to defer loading JavaScript until a component begins rendering. This
235239

236240
| Type | Description |
237241
| --- | --- |
238-
| `Component` | An ReactPy component. |
242+
| `Component` | A ReactPy component. |
239243

240244
??? question "Should I put `django_js` at the bottom of my HTML?"
241245

Diff for: docs/src/features/decorators.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
## Overview
22

3-
!!! summary "Overview"
3+
<p class="intro" markdown>
44

5-
Decorator utilities can be used within your `components.py` to help simplify development.
5+
Decorator functions can be used within your `components.py` to help simplify development.
6+
7+
</p>
8+
9+
---
610

711
## Auth Required
812

@@ -31,7 +35,7 @@ This decorator is commonly used to selectively render a component only if a user
3135

3236
| Type | Description |
3337
| --- | --- |
34-
| `Component` | An ReactPy component. |
38+
| `Component` | A ReactPy component. |
3539
| `VdomDict` | An `reactpy.html` snippet. |
3640
| `None` | No component render. |
3741

Diff for: docs/src/features/hooks.md

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
## Overview
22

3-
!!! summary "Overview"
3+
<p class="intro" markdown>
44

5-
Prefabricated hooks can be used within your `components.py` to help simplify development.
5+
Prefabricated hooks can be used within your `components.py` to help simplify development.
66

7-
??? tip "Looking for standard React hooks?"
7+
</p>
88

9-
The `reactpy-django` package only contains django specific hooks. Standard hooks can be found within [`reactive-python/reactpy`](https://github.com/reactive-python/reactpy). Since `reactpy` is installed alongside `reactpy-django`, you can import them at any time.
9+
!!! note
1010

11-
Check out the [ReactPy Core docs](https://reactpy.dev/docs/reference/hooks-api.html#basic-hooks) to see what hooks are available!
11+
Looking for standard React hooks?
12+
13+
This package only contains Django specific hooks. Standard hooks can be found within [`reactive-python/reactpy`](https://reactpy.dev/docs/reference/hooks-api.html#basic-hooks).
14+
15+
---
1216

1317
## Use Query
1418

Diff for: docs/src/features/settings.md

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
## Overview
22

3-
!!! summary "Overview"
3+
<p class="intro" markdown>
44

5-
Your **Django project's** `settings.py` can modify the behavior of ReactPy.
5+
Your **Django project's** `settings.py` can modify the behavior of ReactPy.
6+
7+
</p>
8+
9+
!!! note
10+
11+
The default configuration of ReactPy is suitable for the vast majority of use cases.
12+
13+
You should only consider changing settings when the necessity arises.
14+
15+
---
616

717
## Primary Configuration
818

@@ -13,18 +23,12 @@ These are ReactPy-Django's default settings values. You can modify these values
1323
| Setting | Default Value | Example Value(s) | Description |
1424
| --- | --- | --- | --- |
1525
| `REACTPY_CACHE` | `#!python "default"` | `#!python "my-reactpy-cache"` | Cache used to store ReactPy web modules. ReactPy benefits from a fast, well indexed cache.<br/>We recommend installing [`redis`](https://redis.io/) or [`python-diskcache`](https://grantjenks.com/docs/diskcache/tutorial.html#djangocache). |
16-
| `REACTPY_DATABASE` | `#!python "default"` | `#!python "my-reactpy-database"` | Database ReactPy uses to store session data. ReactPy requires a multiprocessing-safe and thread-safe database.<br/>If configuring `REACTPY_DATABASE`, it is mandatory to also configure `DATABASE_ROUTERS` like such:<br/>`#!python DATABASE_ROUTERS = ["reactpy_django.database.Router", ...]` |
26+
| `REACTPY_DATABASE` | `#!python "default"` | `#!python "my-reactpy-database"` | Database used to store ReactPy session data. ReactPy requires a multiprocessing-safe and thread-safe database.<br/>If configuring `REACTPY_DATABASE`, it is mandatory to use our database router like such:<br/>`#!python DATABASE_ROUTERS = ["reactpy_django.database.Router", ...]` |
1727
| `REACTPY_RECONNECT_MAX` | `#!python 259200` | `#!python 96000`, `#!python 60`, `#!python 0` | Maximum seconds between reconnection attempts before giving up.<br/>Use `#!python 0` to prevent reconnection. |
1828
| `REACTPY_URL_PREFIX` | `#!python "reactpy/"` | `#!python "rp/"`, `#!python "render/reactpy/"` | The prefix to be used for all ReactPy websocket and HTTP URLs. |
1929
| `REACTPY_DEFAULT_QUERY_POSTPROCESSOR` | `#!python "reactpy_django.utils.django_query_postprocessor"` | `#!python "example_project.my_query_postprocessor"` | Dotted path to the default `reactpy_django.hooks.use_query` postprocessor function. |
2030
| `REACTPY_AUTH_BACKEND` | `#!python "django.contrib.auth.backends.ModelBackend"` | `#!python "example_project.auth.MyModelBackend"` | Dotted path to the Django authentication backend to use for ReactPy components. This is only needed if:<br/> 1. You are using `AuthMiddlewareStack` and...<br/> 2. You are using Django's `AUTHENTICATION_BACKENDS` setting and...<br/> 3. Your Django user model does not define a `backend` attribute. |
2131
| `REACTPY_BACKHAUL_THREAD` | `#!python False` | `#!python True` | Whether to render ReactPy components in a dedicated thread. This allows the webserver to process web traffic while during ReactPy rendering.<br/>Vastly improves throughput with web servers such as `hypercorn` and `uvicorn`. |
22-
| `REACTPY_DEFAULT_HOSTS` | `#!python None` | `#!python ["localhost:8000", "localhost:8001", "localhost:8002/subdir" ]` | Default host(s) to use for ReactPy components. ReactPy will use these hosts in a round-robin fashion, allowing for easy distributed computing.<br/>You can use the `host` argument in your [template tag](../features/template-tag.md#component) to override this default. |
32+
| `REACTPY_DEFAULT_HOSTS` | `#!python None` | `#!python ["localhost:8000", "localhost:8001", "localhost:8002/subdir" ]` | The default host(s) that can render your ReactPy components. ReactPy will use these hosts in a round-robin fashion, allowing for easy distributed computing.<br/>You can use the `host` argument in your [template tag](../features/template-tag.md#component) as a manual override. |
2333

2434
<!--config-details-end-->
25-
26-
??? question "Do I need to modify my settings?"
27-
28-
The default configuration of ReactPy is suitable for the majority of use cases.
29-
30-
You should only consider changing settings when the necessity arises.

Diff for: docs/src/features/template-tag.md

+9-21
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
## Overview
22

3-
!!! summary "Overview"
3+
<p class="intro" markdown>
44

5-
Template tags can be used within your Django templates such as `my-template.html` to import ReactPy features.
5+
Django template tags can be used within your HTML templates to provide ReactPy features.
6+
7+
</p>
8+
9+
---
610

711
## Component
812

@@ -20,14 +24,16 @@ The `component` template tag can be used to insert any number of ReactPy compone
2024
| --- | --- | --- | --- |
2125
| `dotted_path` | `str` | The dotted path to the component to render. | N/A |
2226
| `*args` | `Any` | The positional arguments to provide to the component. | N/A |
27+
| `class` | `str | None` | The HTML class to apply to the top-level component div. | `None` |
28+
| `key` | `str | None` | Force the component's root node to use a [specific key value](https://reactpy.dev/docs/guides/creating-interfaces/rendering-data/index.html#organizing-items-with-keys). Using `key` within a template tag is effectively useless. | `None` |
2329
| `host` | `str | None` | The host to use for the ReactPy connections. If set to `None`, the host will be automatically configured.<br/>Example values include: `localhost:8000`, `example.com`, `example.com/subdir` | `None` |
2430
| `**kwargs` | `Any` | The keyword arguments to provide to the component. | N/A |
2531

2632
<font size="4">**Returns**</font>
2733

2834
| Type | Description |
2935
| --- | --- |
30-
| `Component` | An ReactPy component. |
36+
| `Component` | A ReactPy component. |
3137

3238
<!--context-start-->
3339

@@ -56,24 +62,6 @@ The `component` template tag can be used to insert any number of ReactPy compone
5662
```
5763

5864
<!--context-end-->
59-
<!--reserved-arg-start-->
60-
61-
??? info "Reserved keyword arguments: `class` and `key`"
62-
63-
For this template tag, there are two reserved keyword arguments: `class` and `key`
64-
65-
- `class` allows you to apply a HTML class to the top-level component div. This is useful for styling purposes.
66-
- `key` allows you to force the component's root node to use a [specific key value](https://reactpy.dev/docs/guides/creating-interfaces/rendering-data/index.html#organizing-items-with-keys). Using `key` within a template tag is effectively useless.
67-
68-
=== "my-template.html"
69-
70-
```jinja
71-
...
72-
{% component "example.components.my_component" class="my-html-class" key=123 %}
73-
...
74-
```
75-
76-
<!--reserved-sarg-end-->
7765

7866
??? question "Can I render components on a different server (distributed computing)?"
7967

0 commit comments

Comments
 (0)