From 05519acb25ff8f42ef0b991073108783c34d337a Mon Sep 17 00:00:00 2001
From: Dominik George <dominik.george@teckids.org>
Date: Wed, 23 Nov 2022 10:15:45 +0000
Subject: [PATCH] Document forms.py

---
 django_forms_as_jsonschema/forms.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/django_forms_as_jsonschema/forms.py b/django_forms_as_jsonschema/forms.py
index 207a662..570b1fc 100644
--- a/django_forms_as_jsonschema/forms.py
+++ b/django_forms_as_jsonschema/forms.py
@@ -4,13 +4,19 @@ from .jsonschema import JSONSchema
 
 
 class JSONSchemaFormMixin:
+    """Mixin to extend Django forms with a converter into a JSON schema."""
     layout = None
 
     def as_jsonschema(self: Form) -> dict:
+        """Encode form fields and layout into a JSON schema."""
         schema = JSONSchema()
+
         if self.layout is None:
+            # If no layout is provided, simply add all fields as individual rows
             for name, field in self.fields.items():
                 schema.add_field(name, field)
         else:
+            # Offload generation to the layout class
             schema.update_properties(self.layout.build_schema(schema, self.fields)["properties"])
+
         return schema.schema
-- 
GitLab