refactor: Assign content of file from Component.template_file to Component.template (#880)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Juro Oravec 2025-01-07 19:34:34 +01:00 committed by GitHub
parent 8e2428ebd0
commit 1e4b556b4d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 399 additions and 186 deletions

View file

@ -551,6 +551,22 @@ def gen_reference_templatevars():
f.write(f"::: {ComponentVars.__module__}.{ComponentVars.__name__}.{field}\n\n")
# NOTE: Unlike other references, the API of Signals is not yet codified (AKA source of truth defined
# as Python code). Instead, we manually list all signals that are sent by django-components.
def gen_reference_signals():
"""
Generate documentation for all [Django Signals](https://docs.djangoproject.com/en/5.1/ref/signals) that are
send by or during the use of django-components.
"""
preface = "<!-- Autogenerated by reference.py -->\n\n"
preface += (root / "docs/templates/reference_signals.md").read_text()
out_file = root / "docs/reference/signals.md"
out_file.parent.mkdir(parents=True, exist_ok=True)
with out_file.open("w", encoding="utf-8") as f:
f.write(preface + "\n\n")
def _list_urls(urlpatterns: Sequence[Union[URLPattern, URLResolver]], prefix=""):
"""Recursively extract all URLs and their associated views from Django's urlpatterns"""
urls: List[str] = []
@ -732,6 +748,7 @@ def gen_reference():
gen_reference_commands()
gen_reference_templatetags()
gen_reference_templatevars()
gen_reference_signals()
# This is run when `gen-files` plugin is run in mkdocs.yml