Python wrapper for Decko — build, validate, and render presentations programmatically
Project description
decko-py
Python wrapper for Decko — build, validate, and render presentations programmatically.
Install
pip install decko-py
Quick start
from decko_py import DeckBuilder, TextBlock, Slide
html = (
DeckBuilder()
.meta("My Presentation", author="Alice")
.theme("midnight")
.slide(
Slide(
template_id="title",
slots={"headline": TextBlock(content="Hello, World!", display="hero")},
)
)
.render_html()
)
# or save to file
DeckBuilder().meta("My Deck").theme("nova").slide(...).save("deck.html")
Models
All Pydantic v2 models. Import from decko_py or decko_py.models:
from decko_py import (
Deck, DeckMeta, DeckTheme, Slide,
TextBlock, CodeBlock, ListBlock, MediaBlock,
MetricBlock, ChartBlock, ChartData, ChartDataset,
TableBlock, CalloutBlock, DividerBlock, GroupBlock,
XBlock, BlockAnimation, Composition,
FadeTransition, PanTransition,
)
Serialization
All models serialize to camelCase JSON (matching the TypeScript schema):
block = TextBlock(content="Hello", display="heading")
block.model_dump(by_alias=True)
# {"type": "text", "display": "heading", "content": "Hello"}
Custom blocks
Register server-side renderers for x-* blocks:
from decko_py import BlockRegistry, XBlock
registry = BlockRegistry()
@registry.register("x-badge")
def render_badge(block: XBlock) -> str:
return f'<span class="badge">{block.props["label"]}</span>'
html = DeckBuilder()...render_html(block_registry=registry)
Validation
from decko_py import validate_content, TemplateRegistry, TemplateDefinition
reg = TemplateRegistry()
reg.register(TemplateDefinition(...))
violations = validate_content(deck, reg)
for v in violations:
print(f"Slide {v.slide_index}, slot '{v.slot_id}': {v.field} exceeded ({v.actual} > {v.budget})")
CDN config
from decko_py import CdnConfig, HtmlRenderer
cdn = CdnConfig(version="1.2.3")
renderer = HtmlRenderer(cdn=cdn)
html = renderer.render(deck)
Development
git clone https://github.com/rchrdcrngl/decko_python.git
cd decko_python
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest
ruff check src/ tests/
mypy src/decko_py
CI/CD
- CI: runs on every push/PR — lint (ruff), type check (mypy), tests (pytest) across Python 3.10–3.12
- Publish: triggers on GitHub release → builds wheel + sdist → publishes to PyPI via OIDC trusted publishing (no API key required)
License
MIT
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 decko_py-0.1.0.tar.gz.
File metadata
- Download URL: decko_py-0.1.0.tar.gz
- Upload date:
- Size: 20.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdfa6bd9a28be1d854ef2b83e1408d2ec0f2f85b01abd6746f283b8f3990ccf2
|
|
| MD5 |
4451f82d10541fc5e7f372c542dec3f3
|
|
| BLAKE2b-256 |
9d798c6c9c48cbb425b7e9cca42ec51a4bbf0950aa35e592cb264c89eb9f4577
|
Provenance
The following attestation bundles were made for decko_py-0.1.0.tar.gz:
Publisher:
publish.yml on rchrdcrngl/decko_python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
decko_py-0.1.0.tar.gz -
Subject digest:
bdfa6bd9a28be1d854ef2b83e1408d2ec0f2f85b01abd6746f283b8f3990ccf2 - Sigstore transparency entry: 1680001794
- Sigstore integration time:
-
Permalink:
rchrdcrngl/decko_python@297e809e41606e77cc026db53a7d111b0e791bf2 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/rchrdcrngl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@297e809e41606e77cc026db53a7d111b0e791bf2 -
Trigger Event:
release
-
Statement type:
File details
Details for the file decko_py-0.1.0-py3-none-any.whl.
File metadata
- Download URL: decko_py-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39015124cfb71eef7470a60d8afd2e0478a512751c745d4082d8f210a31b8979
|
|
| MD5 |
9f41db6f691f5c642f1c827c327f2278
|
|
| BLAKE2b-256 |
c93ed09e8a7dfd835a20a7343f0e18d0c6ad051f4359218de56950838430cff5
|
Provenance
The following attestation bundles were made for decko_py-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on rchrdcrngl/decko_python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
decko_py-0.1.0-py3-none-any.whl -
Subject digest:
39015124cfb71eef7470a60d8afd2e0478a512751c745d4082d8f210a31b8979 - Sigstore transparency entry: 1680001895
- Sigstore integration time:
-
Permalink:
rchrdcrngl/decko_python@297e809e41606e77cc026db53a7d111b0e791bf2 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/rchrdcrngl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@297e809e41606e77cc026db53a7d111b0e791bf2 -
Trigger Event:
release
-
Statement type: