Skip to content

Move docs examples from python to examples/python #214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/test-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ jobs:
run: |
pip install -r requirements/check-types.txt
pip install -r requirements/check-style.txt
mypy --show-error-codes docs/python/
black docs/python/ --check
ruff check docs/python/
mypy --show-error-codes docs/examples/python/
black docs/examples/python/ --check
ruff check docs/examples/python/
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions docs/src/learn/add-reactpy-to-a-django-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Add `#!python "reactpy_django"` to [`INSTALLED_APPS`](https://docs.djangoproject
=== "settings.py"

```python
{% include "../../python/configure-installed-apps.py" %}
{% include "../../examples/python/configure-installed-apps.py" %}
```

??? warning "Enable ASGI and Django Channels (Required)"
Expand All @@ -42,13 +42,13 @@ Add `#!python "reactpy_django"` to [`INSTALLED_APPS`](https://docs.djangoproject
2. Add `#!python "daphne"` to `#!python INSTALLED_APPS`.

```python linenums="0"
{% include "../../python/configure-channels-installed-app.py" %}
{% include "../../examples/python/configure-channels-installed-app.py" %}
```

3. Set your `#!python ASGI_APPLICATION` variable.

```python linenums="0"
{% include "../../python/configure-channels-asgi-app.py" %}
{% include "../../examples/python/configure-channels-asgi-app.py" %}
```

??? info "Configure ReactPy settings (Optional)"
Expand All @@ -64,7 +64,7 @@ Add ReactPy HTTP paths to your `#!python urlpatterns` in your [`urls.py`](https:
=== "urls.py"

```python
{% include "../../python/configure-urls.py" %}
{% include "../../examples/python/configure-urls.py" %}
```

## Step 4: Configure `asgi.py`
Expand All @@ -74,7 +74,7 @@ Register ReactPy's WebSocket using `#!python REACTPY_WEBSOCKET_ROUTE` in your [`
=== "asgi.py"

```python
{% include "../../python/configure-asgi.py" %}
{% include "../../examples/python/configure-asgi.py" %}
```

??? info "Add `#!python AuthMiddlewareStack` (Optional)"
Expand All @@ -88,7 +88,7 @@ Register ReactPy's WebSocket using `#!python REACTPY_WEBSOCKET_ROUTE` in your [`
In these situations will need to ensure you are using `#!python AuthMiddlewareStack`.

```python linenums="0"
{% include "../../python/configure-asgi-middleware.py" start="# start" %}
{% include "../../examples/python/configure-asgi-middleware.py" start="# start" %}
```

??? question "Where is my `asgi.py`?"
Expand Down
4 changes: 2 additions & 2 deletions docs/src/learn/your-first-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ Within your **Django app**'s `views.py` file, you will need to [create a view fu
=== "views.py"

```python
{% include "../../python/example/views.py" %}
{% include "../../examples/python/example/views.py" %}
```

We will add this new view into your [`urls.py`](https://docs.djangoproject.com/en/dev/intro/tutorial01/#write-your-first-view) and define what URL it should be accessible at.

=== "urls.py"

```python
{% include "../../python/example/urls.py" %}
{% include "../../examples/python/example/urls.py" %}
```

??? question "Which urls.py do I add my views to?"
Expand Down
56 changes: 28 additions & 28 deletions docs/src/reference/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ Compatible with sync or async [Function Based Views](https://docs.djangoproject.
=== "components.py"

```python
{% include "../../python/vtc.py" %}
{% include "../../examples/python/vtc.py" %}
```

=== "views.py"

```python
{% include "../../python/hello_world_fbv.py" %}
{% include "../../examples/python/hello_world_fbv.py" %}
```

??? example "See Interface"
Expand Down Expand Up @@ -61,13 +61,13 @@ Compatible with sync or async [Function Based Views](https://docs.djangoproject.
=== "components.py"

```python
{% include "../../python/vtc-cbv.py" %}
{% include "../../examples/python/vtc-cbv.py" %}
```

=== "views.py"

```python
{% include "../../python/hello_world_cbv.py" %}
{% include "../../examples/python/hello_world_cbv.py" %}
```

??? question "How do I provide `#!python request`, `#!python args`, and `#!python kwargs` to a converted view?"
Expand All @@ -77,13 +77,13 @@ Compatible with sync or async [Function Based Views](https://docs.djangoproject.
=== "components.py"

```python
{% include "../../python/vtc-args.py" %}
{% include "../../examples/python/vtc-args.py" %}
```

=== "views.py"

```python
{% include "../../python/hello_world_args_kwargs.py" %}
{% include "../../examples/python/hello_world_args_kwargs.py" %}
```

??? question "How do I customize this component's behavior?"
Expand All @@ -105,13 +105,13 @@ Compatible with sync or async [Function Based Views](https://docs.djangoproject.
=== "components.py"

```python
{% include "../../python/vtc-strict-parsing.py" %}
{% include "../../examples/python/vtc-strict-parsing.py" %}
```

=== "views.py"

```python
{% include "../../python/hello_world_fbv.py" %}
{% include "../../examples/python/hello_world_fbv.py" %}
```

---
Expand All @@ -127,13 +127,13 @@ Compatible with sync or async [Function Based Views](https://docs.djangoproject.
=== "components.py"

```python
{% include "../../python/vtc-transforms.py" %}
{% include "../../examples/python/vtc-transforms.py" %}
```

=== "views.py"

```python
{% include "../../python/hello_world_fbv_with_id.py" %}
{% include "../../examples/python/hello_world_fbv_with_id.py" %}
```

---
Expand All @@ -149,19 +149,19 @@ Compatible with sync or async [Function Based Views](https://docs.djangoproject.
=== "components.py"

```python
{% include "../../python/vti.py" %}
{% include "../../examples/python/vti.py" %}
```

=== "views.py"

```python
{% include "../../python/hello_world_fbv.py" %}
{% include "../../examples/python/hello_world_fbv.py" %}
```

=== "apps.py"

```python
{% include "../../python/hello_world_app_config_fbv.py" %}
{% include "../../examples/python/hello_world_app_config_fbv.py" %}
```

??? example "See Interface"
Expand Down Expand Up @@ -198,19 +198,19 @@ Compatible with sync or async [Function Based Views](https://docs.djangoproject.
=== "components.py"

```python
{% include "../../python/vti-cbv.py" %}
{% include "../../examples/python/vti-cbv.py" %}
```

=== "views.py"

```python
{% include "../../python/hello_world_cbv.py" %}
{% include "../../examples/python/hello_world_cbv.py" %}
```

=== "apps.py"

```python
{% include "../../python/hello_world_app_config_cbv.py" %}
{% include "../../examples/python/hello_world_app_config_cbv.py" %}
```

??? question "How do I provide `#!python args` and `#!python kwargs` to a converted view?"
Expand All @@ -222,19 +222,19 @@ Compatible with sync or async [Function Based Views](https://docs.djangoproject.
=== "components.py"

```python
{% include "../../python/vti-args.py" %}
{% include "../../examples/python/vti-args.py" %}
```

=== "views.py"

```python
{% include "../../python/hello_world_fbv.py" %}
{% include "../../examples/python/hello_world_fbv.py" %}
```

=== "apps.py"

```python
{% include "../../python/hello_world_app_config_fbv.py" %}
{% include "../../examples/python/hello_world_app_config_fbv.py" %}
```

??? question "How do I customize this component's behavior?"
Expand All @@ -254,19 +254,19 @@ Compatible with sync or async [Function Based Views](https://docs.djangoproject.
=== "components.py"

```python
{% include "../../python/vti-extra-props.py" %}
{% include "../../examples/python/vti-extra-props.py" %}
```

=== "views.py"

```python
{% include "../../python/hello_world_fbv.py" %}
{% include "../../examples/python/hello_world_fbv.py" %}
```

=== "apps.py"

```python
{% include "../../python/hello_world_app_config_fbv.py" %}
{% include "../../examples/python/hello_world_app_config_fbv.py" %}
```

---
Expand All @@ -278,7 +278,7 @@ Allows you to defer loading a CSS stylesheet until a component begins rendering.
=== "components.py"

```python
{% include "../../python/django-css.py" %}
{% include "../../examples/python/django-css.py" %}
```

??? example "See Interface"
Expand All @@ -303,7 +303,7 @@ Allows you to defer loading a CSS stylesheet until a component begins rendering.
Here's an example on what you should avoid doing for Django static files:

```python
{% include "../../python/django-css-local-link.py" %}
{% include "../../examples/python/django-css-local-link.py" %}
```

??? question "How do I load external CSS?"
Expand All @@ -313,7 +313,7 @@ Allows you to defer loading a CSS stylesheet until a component begins rendering.
For external CSS, you should use `#!python html.link`.

```python
{% include "../../python/django-css-external-link.py" %}
{% include "../../examples/python/django-css-external-link.py" %}
```

??? question "Why not load my CSS in `#!html <head>`?"
Expand All @@ -340,7 +340,7 @@ Be mindful of load order! If your JavaScript relies on the component existing on
=== "components.py"

```python
{% include "../../python/django-js.py" %}
{% include "../../examples/python/django-js.py" %}
```

??? example "See Interface"
Expand All @@ -365,7 +365,7 @@ Be mindful of load order! If your JavaScript relies on the component existing on
Here's an example on what you should avoid doing for Django static files:

```python
{% include "../../python/django-js-local-script.py" %}
{% include "../../examples/python/django-js-local-script.py" %}
```

??? question "How do I load external JS?"
Expand All @@ -375,7 +375,7 @@ Be mindful of load order! If your JavaScript relies on the component existing on
For external JavaScript, you should use `#!python html.script`.

```python
{% include "../../python/django-js-remote-script.py" %}
{% include "../../examples/python/django-js-remote-script.py" %}
```

??? question "Why not load my JS in `#!html <head>`?"
Expand Down
6 changes: 3 additions & 3 deletions docs/src/reference/decorators.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This decorator is inspired by Django's [`user_passes_test`](http://docs.djangopr
=== "components.py"

```python
{% include "../../python/user-passes-test.py" %}
{% include "../../examples/python/user-passes-test.py" %}
```

??? example "See Interface"
Expand All @@ -42,7 +42,7 @@ This decorator is inspired by Django's [`user_passes_test`](http://docs.djangopr
=== "components.py"

```python
{% include "../../python/user-passes-test-component-fallback.py" %}
{% include "../../examples/python/user-passes-test-component-fallback.py" %}
```

??? question "How do I render a simple `#!python reactpy.html` snippet if the test fails?"
Expand All @@ -52,5 +52,5 @@ This decorator is inspired by Django's [`user_passes_test`](http://docs.djangopr
=== "components.py"

```python
{% include "../../python/user-passes-test-vdom-fallback.py" %}
{% include "../../examples/python/user-passes-test-vdom-fallback.py" %}
```
Loading