mirror of
https://github.com/django-components/django-components.git
synced 2025-09-19 12:19:44 +00:00
docs: update auto-gen'd docs to show signals reference page (#926)
This commit is contained in:
parent
914576e681
commit
6ccc2fe0f4
5 changed files with 164 additions and 103 deletions
|
@ -3,6 +3,10 @@
|
||||||
# API
|
# API
|
||||||
|
|
||||||
|
|
||||||
|
::: django_components.BaseNode
|
||||||
|
options:
|
||||||
|
show_if_no_docstring: true
|
||||||
|
|
||||||
::: django_components.Component
|
::: django_components.Component
|
||||||
options:
|
options:
|
||||||
show_if_no_docstring: true
|
show_if_no_docstring: true
|
||||||
|
@ -11,6 +15,14 @@
|
||||||
options:
|
options:
|
||||||
show_if_no_docstring: true
|
show_if_no_docstring: true
|
||||||
|
|
||||||
|
::: django_components.ComponentMediaInput
|
||||||
|
options:
|
||||||
|
show_if_no_docstring: true
|
||||||
|
|
||||||
|
::: django_components.ComponentMediaInputPath
|
||||||
|
options:
|
||||||
|
show_if_no_docstring: true
|
||||||
|
|
||||||
::: django_components.ComponentRegistry
|
::: django_components.ComponentRegistry
|
||||||
options:
|
options:
|
||||||
show_if_no_docstring: true
|
show_if_no_docstring: true
|
||||||
|
@ -103,3 +115,7 @@
|
||||||
options:
|
options:
|
||||||
show_if_no_docstring: true
|
show_if_no_docstring: true
|
||||||
|
|
||||||
|
::: django_components.template_tag
|
||||||
|
options:
|
||||||
|
show_if_no_docstring: true
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,57 @@ These are all the [Django management commands](https://docs.djangoproject.com/en
|
||||||
that will be added by installing `django_components`:
|
that will be added by installing `django_components`:
|
||||||
|
|
||||||
|
|
||||||
|
## `upgradecomponent`
|
||||||
|
|
||||||
|
```txt
|
||||||
|
usage: manage.py upgradecomponent [-h] [--path PATH] [--version] [-v {0,1,2,3}] [--settings SETTINGS]
|
||||||
|
[--pythonpath PYTHONPATH] [--traceback] [--no-color] [--force-color]
|
||||||
|
[--skip-checks]
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/django-components/django-components/tree/master/src/django_components/management/commands/upgradecomponent.py#L12" target="_blank">See source code</a>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Updates component and component_block tags to the new syntax
|
||||||
|
|
||||||
|
**Options:**
|
||||||
|
|
||||||
|
- `-h`, `--help`
|
||||||
|
- show this help message and exit
|
||||||
|
- `--path PATH`
|
||||||
|
- Path to search for components
|
||||||
|
- `--version`
|
||||||
|
- Show program's version number and exit.
|
||||||
|
- `-v {0,1,2,3}`, `--verbosity {0,1,2,3}`
|
||||||
|
- Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output
|
||||||
|
- `--settings SETTINGS`
|
||||||
|
- The Python path to a settings module, e.g. "myproject.settings.main". If this isn't provided, the DJANGO_SETTINGS_MODULE environment variable will be used.
|
||||||
|
- `--pythonpath PYTHONPATH`
|
||||||
|
- A directory to add to the Python path, e.g. "/home/djangoprojects/myproject".
|
||||||
|
- `--traceback`
|
||||||
|
- Raise on CommandError exceptions.
|
||||||
|
- `--no-color`
|
||||||
|
- Don't colorize the command output.
|
||||||
|
- `--force-color`
|
||||||
|
- Force colorization of the command output.
|
||||||
|
- `--skip-checks`
|
||||||
|
- Skip system checks.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## `startcomponent`
|
## `startcomponent`
|
||||||
|
|
||||||
```txt
|
```txt
|
||||||
usage: manage.py startcomponent [-h] [--path PATH] [--js JS] [--css CSS] [--template TEMPLATE] [--force] [--verbose]
|
usage: manage.py startcomponent [-h] [--path PATH] [--js JS] [--css CSS] [--template TEMPLATE] [--force]
|
||||||
[--dry-run] [--version] [-v {0,1,2,3}] [--settings SETTINGS] [--pythonpath PYTHONPATH]
|
[--verbose] [--dry-run] [--version] [-v {0,1,2,3}] [--settings SETTINGS]
|
||||||
[--traceback] [--no-color] [--force-color] [--skip-checks]
|
[--pythonpath PYTHONPATH] [--traceback] [--no-color] [--force-color]
|
||||||
|
[--skip-checks]
|
||||||
name
|
name
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -122,46 +167,3 @@ python manage.py startcomponent my_component --dry-run
|
||||||
This will simulate the creation of `my_component` without creating any files.
|
This will simulate the creation of `my_component` without creating any files.
|
||||||
|
|
||||||
|
|
||||||
## `upgradecomponent`
|
|
||||||
|
|
||||||
```txt
|
|
||||||
usage: manage.py upgradecomponent [-h] [--path PATH] [--version] [-v {0,1,2,3}] [--settings SETTINGS]
|
|
||||||
[--pythonpath PYTHONPATH] [--traceback] [--no-color] [--force-color] [--skip-checks]
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a href="https://github.com/django-components/django-components/tree/master/src/django_components/management/commands/upgradecomponent.py#L12" target="_blank">See source code</a>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Updates component and component_block tags to the new syntax
|
|
||||||
|
|
||||||
**Options:**
|
|
||||||
|
|
||||||
- `-h`, `--help`
|
|
||||||
- show this help message and exit
|
|
||||||
- `--path PATH`
|
|
||||||
- Path to search for components
|
|
||||||
- `--version`
|
|
||||||
- Show program's version number and exit.
|
|
||||||
- `-v {0,1,2,3}`, `--verbosity {0,1,2,3}`
|
|
||||||
- Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output
|
|
||||||
- `--settings SETTINGS`
|
|
||||||
- The Python path to a settings module, e.g. "myproject.settings.main". If this isn't provided, the DJANGO_SETTINGS_MODULE environment variable will be used.
|
|
||||||
- `--pythonpath PYTHONPATH`
|
|
||||||
- A directory to add to the Python path, e.g. "/home/djangoprojects/myproject".
|
|
||||||
- `--traceback`
|
|
||||||
- Raise on CommandError exceptions.
|
|
||||||
- `--no-color`
|
|
||||||
- Don't colorize the command output.
|
|
||||||
- `--force-color`
|
|
||||||
- Force colorization of the command output.
|
|
||||||
- `--skip-checks`
|
|
||||||
- Skip system checks.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
41
docs/reference/signals.md
Normal file
41
docs/reference/signals.md
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
<!-- Autogenerated by reference.py -->
|
||||||
|
|
||||||
|
# Signals
|
||||||
|
|
||||||
|
Below are the signals that are sent by or during the use of django-components.
|
||||||
|
|
||||||
|
## template_rendered
|
||||||
|
|
||||||
|
Django's [`template_rendered`](https://docs.djangoproject.com/en/5.1/ref/signals/#template-rendered) signal.
|
||||||
|
This signal is sent when a template is rendered.
|
||||||
|
|
||||||
|
Django-components triggers this signal when a component is rendered. If there are nested components,
|
||||||
|
the signal is triggered for each component.
|
||||||
|
|
||||||
|
Import from django as `django.test.signals.template_rendered`.
|
||||||
|
|
||||||
|
```python
|
||||||
|
from django.test.signals import template_rendered
|
||||||
|
|
||||||
|
# Setup a callback function
|
||||||
|
def my_callback(sender, **kwargs):
|
||||||
|
...
|
||||||
|
|
||||||
|
template_rendered.connect(my_callback)
|
||||||
|
|
||||||
|
class MyTable(Component):
|
||||||
|
template = """
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>Header</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Cell</td>
|
||||||
|
</tr>
|
||||||
|
"""
|
||||||
|
|
||||||
|
# This will trigger the signal
|
||||||
|
MyTable().render()
|
||||||
|
```
|
||||||
|
|
||||||
|
|
|
@ -12,16 +12,62 @@ Import as
|
||||||
{% load component_tags %}
|
{% load component_tags %}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## component_css_dependencies
|
||||||
|
|
||||||
|
```django
|
||||||
|
{% component_css_dependencies %}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L1170" target="_blank">See source code</a>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Marks location where CSS link tags should be rendered after the whole HTML has been generated.
|
||||||
|
|
||||||
|
Generally, this should be inserted into the `<head>` tag of the HTML.
|
||||||
|
|
||||||
|
If the generated HTML does NOT contain any `{% component_css_dependencies %}` tags, CSS links
|
||||||
|
are by default inserted into the `<head>` tag of the HTML. (See
|
||||||
|
[JS and CSS output locations](../../concepts/advanced/rendering_js_css/#js-and-css-output-locations))
|
||||||
|
|
||||||
|
Note that there should be only one `{% component_css_dependencies %}` for the whole HTML document.
|
||||||
|
If you insert this tag multiple times, ALL CSS links will be duplicately inserted into ALL these places.
|
||||||
|
|
||||||
|
## component_js_dependencies
|
||||||
|
|
||||||
|
```django
|
||||||
|
{% component_js_dependencies %}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L1192" target="_blank">See source code</a>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Marks location where JS link tags should be rendered after the whole HTML has been generated.
|
||||||
|
|
||||||
|
Generally, this should be inserted at the end of the `<body>` tag of the HTML.
|
||||||
|
|
||||||
|
If the generated HTML does NOT contain any `{% component_js_dependencies %}` tags, JS scripts
|
||||||
|
are by default inserted at the end of the `<body>` tag of the HTML. (See
|
||||||
|
[JS and CSS output locations](../../concepts/advanced/rendering_js_css/#js-and-css-output-locations))
|
||||||
|
|
||||||
|
Note that there should be only one `{% component_js_dependencies %}` for the whole HTML document.
|
||||||
|
If you insert this tag multiple times, ALL JS scripts will be duplicately inserted into ALL these places.
|
||||||
|
|
||||||
## component
|
## component
|
||||||
|
|
||||||
```django
|
```django
|
||||||
{% component [arg, ...] **kwargs [only] %}
|
{% component *args: Any, **kwargs: Any [only] %}
|
||||||
{% endcomponent %}
|
{% endcomponent %}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L117" target="_blank">See source code</a>
|
<a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L1516" target="_blank">See source code</a>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,62 +166,16 @@ can access only the data that was explicitly passed to it:
|
||||||
{% component "name" positional_arg keyword_arg=value ... only %}
|
{% component "name" positional_arg keyword_arg=value ... only %}
|
||||||
```
|
```
|
||||||
|
|
||||||
## component_css_dependencies
|
|
||||||
|
|
||||||
```django
|
|
||||||
{% component_css_dependencies %}
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L117" target="_blank">See source code</a>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Marks location where CSS link tags should be rendered after the whole HTML has been generated.
|
|
||||||
|
|
||||||
Generally, this should be inserted into the `<head>` tag of the HTML.
|
|
||||||
|
|
||||||
If the generated HTML does NOT contain any `{% component_css_dependencies %}` tags, CSS links
|
|
||||||
are by default inserted into the `<head>` tag of the HTML. (See
|
|
||||||
[JS and CSS output locations](../../concepts/advanced/rendering_js_css/#js-and-css-output-locations))
|
|
||||||
|
|
||||||
Note that there should be only one `{% component_css_dependencies %}` for the whole HTML document.
|
|
||||||
If you insert this tag multiple times, ALL CSS links will be duplicately inserted into ALL these places.
|
|
||||||
|
|
||||||
## component_js_dependencies
|
|
||||||
|
|
||||||
```django
|
|
||||||
{% component_js_dependencies %}
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L117" target="_blank">See source code</a>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Marks location where JS link tags should be rendered after the whole HTML has been generated.
|
|
||||||
|
|
||||||
Generally, this should be inserted at the end of the `<body>` tag of the HTML.
|
|
||||||
|
|
||||||
If the generated HTML does NOT contain any `{% component_js_dependencies %}` tags, JS scripts
|
|
||||||
are by default inserted at the end of the `<body>` tag of the HTML. (See
|
|
||||||
[JS and CSS output locations](../../concepts/advanced/rendering_js_css/#js-and-css-output-locations))
|
|
||||||
|
|
||||||
Note that there should be only one `{% component_js_dependencies %}` for the whole HTML document.
|
|
||||||
If you insert this tag multiple times, ALL JS scripts will be duplicately inserted into ALL these places.
|
|
||||||
|
|
||||||
## fill
|
## fill
|
||||||
|
|
||||||
```django
|
```django
|
||||||
{% fill name data=None default=None %}
|
{% fill name: str, *, data: Optional[str] = None, default: Optional[str] = None %}
|
||||||
{% endfill %}
|
{% endfill %}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L117" target="_blank">See source code</a>
|
<a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L466" target="_blank">See source code</a>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -268,12 +268,12 @@ use `{% fill %}` with `name` set to `"default"`:
|
||||||
## html_attrs
|
## html_attrs
|
||||||
|
|
||||||
```django
|
```django
|
||||||
{% html_attrs attrs=None defaults=None **kwargs %}
|
{% html_attrs attrs: Optional[Dict] = None, defaults: Optional[Dict] = None, **kwargs: Any %}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L117" target="_blank">See source code</a>
|
<a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L13" target="_blank">See source code</a>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -330,13 +330,13 @@ renders
|
||||||
## provide
|
## provide
|
||||||
|
|
||||||
```django
|
```django
|
||||||
{% provide name **kwargs %}
|
{% provide name: str, **kwargs: Any %}
|
||||||
{% endprovide %}
|
{% endprovide %}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L117" target="_blank">See source code</a>
|
<a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L9" target="_blank">See source code</a>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -410,13 +410,13 @@ user = self.inject("user_data")["user"]
|
||||||
## slot
|
## slot
|
||||||
|
|
||||||
```django
|
```django
|
||||||
{% slot name **kwargs [default] [required] %}
|
{% slot name: str, **kwargs: Any [default] [required] %}
|
||||||
{% endslot %}
|
{% endslot %}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L117" target="_blank">See source code</a>
|
<a href="https://github.com/django-components/django-components/tree/master/src/django_components/templatetags/component_tags.py#L149" target="_blank">See source code</a>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,4 +22,6 @@ urlpatterns = [
|
||||||
## List of URLs
|
## List of URLs
|
||||||
|
|
||||||
|
|
||||||
- `components/cache/<str:comp_cls_hash>.<str:script_type>/`
|
- `components/cache/<str:comp_cls_hash>.<str:input_hash>.<str:script_type>`
|
||||||
|
|
||||||
|
- `components/cache/<str:comp_cls_hash>.<str:script_type>`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue