Skip to main content

Builder system for genro-bag - grammar, validation, compilation

Project description

genro-builders

Builder system for genro-bag — grammar, validation, compilation, and reactive data binding.

Installation

pip install genro-builders

Quick start

from genro_builders.builders import HtmlBuilder

builder = HtmlBuilder()
body = builder.source.body()
body.div(id='main').p('Hello, world!')

builder.build()
print(builder.output)

Subclass pattern with main() and store()

from genro_builders.builders import HtmlBuilder

class MyPage(HtmlBuilder):
    def store(self, data):
        data['title'] = 'Hello, world!'

    def main(self, source):
        body = source.body()
        body.h1(value='^title')
        self.footer(source)

    def footer(self, source):
        source.footer().p('© 2026')

page = MyPage()
page.build()
print(page.output)

Features

  • Domain-specific grammars — Define elements, validation rules, and components via decorators (@element, @abstract, @component)
  • Named slots — Components can declare insertion points (slots=['left', 'right']) for user content injection
  • Built-in builders — HTML5, Markdown, XSD (schema-driven XML)
  • Reactive pipeline — Build source, resolve ^pointer bindings, render output. Data changes trigger automatic re-render
  • Multi-builder coordinationBuilderManager coordinates multiple builders with a shared data store
  • Renderers and compilers@renderer for serialized output (HTML, Markdown), @compiler for live objects (widgets, workbooks)
  • Node identificationnode_id attribute for O(1) lookup via node_by_id()
  • Validationsub_tags cardinality, parent_tags constraints, typed attribute validation

Architecture

A builder owns the full pipeline:

store(data)   →  main(source)  →  build()  →  render() / compile()  →  output
                      │               │                │
                 @element,      components        string (render)
                 @component     expanded,         or live objects
                 as nodes       ^pointers         (compile)
                                resolved
  • store(data) — optional: populate the data Bag
  • main(source) — entry point: build the element tree
  • build() — materialize: expand components, resolve ^pointer bindings
  • render() — produce serialized output via BagRendererBase
  • compile() — produce live objects via BagCompilerBase

Data changes after build trigger automatic updates via BindingManager.

Documentation

See the docs/ directory for full documentation.

License

Apache License 2.0 — Copyright 2025 Softwell S.r.l.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

genro_builders-0.9.0.tar.gz (164.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

genro_builders-0.9.0-py3-none-any.whl (67.8 kB view details)

Uploaded Python 3

File details

Details for the file genro_builders-0.9.0.tar.gz.

File metadata

  • Download URL: genro_builders-0.9.0.tar.gz
  • Upload date:
  • Size: 164.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for genro_builders-0.9.0.tar.gz
Algorithm Hash digest
SHA256 e7921cc3561b93b2ea60ed21a42c1556ba3378e9a74b93a3e489a6e91f8479cb
MD5 d60b2400d0ce3202b86880e24e36e88c
BLAKE2b-256 a1f65b6ee0804b1e11e62248cc5c9bbbe3cf021fb86e31b5f41cda83cc0ee6f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for genro_builders-0.9.0.tar.gz:

Publisher: publish.yml on genropy/genro-builders

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file genro_builders-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: genro_builders-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 67.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for genro_builders-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5980ccdd0545d5f3b8d3b6cd47cba3df015dee322867277d1ffc68a400b1fb4b
MD5 c9a399073f479ea125f471734b53694d
BLAKE2b-256 6d6f8070cbdcaa2cc16c4c81ecaa0c1ba504803504a5924b2bcd6f8b01e6f77b

See more details on using hashes here.

Provenance

The following attestation bundles were made for genro_builders-0.9.0-py3-none-any.whl:

Publisher: publish.yml on genropy/genro-builders

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page