mirror of
https://github.com/django-components/django-components.git
synced 2025-11-18 14:10:19 +00:00
docs: Add "scenarios" code examples (#1445)
Some checks are pending
Docs - build & deploy / docs (push) Waiting to run
Run tests / build (ubuntu-latest, 3.10) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.11) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.12) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.13) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.8) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.9) (push) Waiting to run
Run tests / build (windows-latest, 3.10) (push) Waiting to run
Run tests / build (windows-latest, 3.11) (push) Waiting to run
Run tests / build (windows-latest, 3.12) (push) Waiting to run
Run tests / build (windows-latest, 3.13) (push) Waiting to run
Run tests / build (windows-latest, 3.8) (push) Waiting to run
Run tests / build (windows-latest, 3.9) (push) Waiting to run
Run tests / test_docs (3.13) (push) Waiting to run
Run tests / test_sampleproject (3.13) (push) Waiting to run
Some checks are pending
Docs - build & deploy / docs (push) Waiting to run
Run tests / build (ubuntu-latest, 3.10) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.11) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.12) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.13) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.8) (push) Waiting to run
Run tests / build (ubuntu-latest, 3.9) (push) Waiting to run
Run tests / build (windows-latest, 3.10) (push) Waiting to run
Run tests / build (windows-latest, 3.11) (push) Waiting to run
Run tests / build (windows-latest, 3.12) (push) Waiting to run
Run tests / build (windows-latest, 3.13) (push) Waiting to run
Run tests / build (windows-latest, 3.8) (push) Waiting to run
Run tests / build (windows-latest, 3.9) (push) Waiting to run
Run tests / test_docs (3.13) (push) Waiting to run
Run tests / test_sampleproject (3.13) (push) Waiting to run
This commit is contained in:
parent
71c489df8e
commit
49afdb49d6
49 changed files with 1550 additions and 260 deletions
|
|
@ -1,3 +1,5 @@
|
|||
from importlib import import_module
|
||||
|
||||
from django.http import HttpRequest
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
|
|
@ -25,10 +27,17 @@ class ExamplesIndexPage(Component):
|
|||
for name in sorted(example_names):
|
||||
# Convert snake_case to PascalCase (e.g. error_fallback -> ErrorFallback)
|
||||
display_name = "".join(word.capitalize() for word in name.split("_"))
|
||||
|
||||
# For the short description, we use the DESCRIPTION variable from the component's module
|
||||
module_name = f"examples.dynamic.{name}.component"
|
||||
module = import_module(module_name)
|
||||
description = getattr(module, "DESCRIPTION", "")
|
||||
|
||||
examples.append(
|
||||
{
|
||||
"name": name, # Original name for URLs
|
||||
"display_name": display_name, # PascalCase for display
|
||||
"description": description,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -65,7 +74,7 @@ class ExamplesIndexPage(Component):
|
|||
{{ example.display_name }}
|
||||
</h2>
|
||||
<p class="text-gray-600 mb-4 flex-grow">
|
||||
{{ example.display_name }} component example
|
||||
{{ example.description }}
|
||||
</p>
|
||||
<a
|
||||
href="/examples/{{ example.name }}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue