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
^pointerbindings, render output. Data changes trigger automatic re-render - Multi-builder coordination —
BuilderManagercoordinates multiple builders with a shared data store - Renderers and compilers —
@rendererfor serialized output (HTML, Markdown),@compilerfor live objects (widgets, workbooks) - Node identification —
node_idattribute for O(1) lookup vianode_by_id() - Validation —
sub_tagscardinality,parent_tagsconstraints, 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 Bagmain(source)— entry point: build the element treebuild()— materialize: expand components, resolve^pointerbindingsrender()— produce serialized output viaBagRendererBasecompile()— produce live objects viaBagCompilerBase
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7921cc3561b93b2ea60ed21a42c1556ba3378e9a74b93a3e489a6e91f8479cb
|
|
| MD5 |
d60b2400d0ce3202b86880e24e36e88c
|
|
| BLAKE2b-256 |
a1f65b6ee0804b1e11e62248cc5c9bbbe3cf021fb86e31b5f41cda83cc0ee6f3
|
Provenance
The following attestation bundles were made for genro_builders-0.9.0.tar.gz:
Publisher:
publish.yml on genropy/genro-builders
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
genro_builders-0.9.0.tar.gz -
Subject digest:
e7921cc3561b93b2ea60ed21a42c1556ba3378e9a74b93a3e489a6e91f8479cb - Sigstore transparency entry: 1212675410
- Sigstore integration time:
-
Permalink:
genropy/genro-builders@931d71c0c854dbb274177fb678e64d18be23aaf9 -
Branch / Tag:
refs/tags/v0.9.0 - Owner: https://github.com/genropy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@931d71c0c854dbb274177fb678e64d18be23aaf9 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5980ccdd0545d5f3b8d3b6cd47cba3df015dee322867277d1ffc68a400b1fb4b
|
|
| MD5 |
c9a399073f479ea125f471734b53694d
|
|
| BLAKE2b-256 |
6d6f8070cbdcaa2cc16c4c81ecaa0c1ba504803504a5924b2bcd6f8b01e6f77b
|
Provenance
The following attestation bundles were made for genro_builders-0.9.0-py3-none-any.whl:
Publisher:
publish.yml on genropy/genro-builders
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
genro_builders-0.9.0-py3-none-any.whl -
Subject digest:
5980ccdd0545d5f3b8d3b6cd47cba3df015dee322867277d1ffc68a400b1fb4b - Sigstore transparency entry: 1212675464
- Sigstore integration time:
-
Permalink:
genropy/genro-builders@931d71c0c854dbb274177fb678e64d18be23aaf9 -
Branch / Tag:
refs/tags/v0.9.0 - Owner: https://github.com/genropy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@931d71c0c854dbb274177fb678e64d18be23aaf9 -
Trigger Event:
push
-
Statement type: