Skip to content

API Reference parrot_formdesigner.renderers.base

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_formdesigner.renderers.base

View source

Abstract base class for form renderers.

All form renderers implement AbstractFormRenderer to produce RenderedForm output from FormSchema + StyleSchema input.

Class AbstractFormRenderer

Abstract base for form renderers.

Subclasses implement render() to convert a FormSchema into a platform-specific representation (Adaptive Card, HTML5, JSON Schema, etc.).

The render() method is async to support renderers that may need to fetch dynamic options or perform I/O.

Method AbstractFormRenderer.render

Render a FormSchema into the target format.

render(form: FormSchema, style: StyleSchema | None = None, *, locale: str = 'en', prefilled: dict[str, Any] | None = None, errors: dict[str, str] | None = None) -> RenderedForm

Parameter Type Default Description
form FormSchema The form schema to render.
style StyleSchema | None None Optional style configuration. Defaults to StyleSchema().
locale str 'en' BCP 47 locale tag for i18n label resolution.
prefilled dict[str, Any] | None None Pre-filled field values (field_id -> value).
errors dict[str, str] | None None Validation errors to display (field_id -> message).

Returns: RenderedForm — RenderedForm with the rendered content and metadata.

Class FallbackRenderer

Concrete fallback emitter — degraded representation.

Each renderer subclasses or instantiates this to define what 'degraded' means for its target. The base implementation returns None — subclasses must override render() to emit target-appropriate content.

Warning appending is the renderer's responsibility (it has access to RenderedForm.warnings once Module 8 is merged).

Method FallbackRenderer.render

Return None as placeholder. Override in renderer-specific subclasses.

render(field: FormField, *, locale: str = 'en', prefilled: Any = None, error: str | None = None) -> Any

Parameter Type Default Description
field FormField
locale str 'en'
prefilled Any None
error str | None None

Returns: Any

Class FieldRenderer

Per-target field renderer. One concrete impl per (FieldType, output target).

The render() signature uses keyword-only args so callers can pass optional context without breaking positional compatibility. Return type is Any because each output target uses a different representation (str for HTML5, dict for Adaptive Card/JSON Schema, bytes for PDF, etc.).

Method FieldRenderer.render

render(field: FormField, *, locale: str = 'en', prefilled: Any = None, error: str | None = None) -> Any

Parameter Type Default Description
field FormField
locale str 'en'
prefilled Any None
error str | None None

Returns: Any

Alias FormField

Re-exported from parrot_formdesigner.core.schema.FormField.

Alias FormSchema

Re-exported from parrot_formdesigner.core.schema.FormSchema.

Alias RenderedForm

Re-exported from parrot_formdesigner.core.schema.RenderedForm.

Alias StyleSchema

Re-exported from parrot_formdesigner.core.style.StyleSchema.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally