Skip to main content

decko-py

Python wrapper for Decko — build, validate, and render presentations programmatically.

Install

pip install decko-py

Quick start

from decko_py import DeckBuilder, TitleSlide

html = (
    DeckBuilder()
    .meta("My Presentation", author="Alice")
    .theme("midnight")
    .slide(TitleSlide(headline="Hello, World!"))
    .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)

Templates

23 built-in templates across 5 categories. Each has a matching typed slide class:

Category Template ID Typed slide class
narrative title-slide TitleSlide
narrative section-break SectionBreakSlide
narrative agenda AgendaSlide
narrative closing ClosingSlide
narrative quote QuoteSlide
content single-column SingleColumnSlide
content two-column TwoColumnSlide
content header-body HeaderBodySlide
content bullets-media BulletsMediaSlide
content three-up ThreeUpSlide
data big-metric BigMetricSlide
data metric-trio MetricTrioSlide
data chart-callout ChartCalloutSlide
data table-slide TableSlide
visual full-bleed-media FullBleedMediaSlide
visual media-caption MediaCaptionSlide
visual image-grid ImageGridSlide
visual comparison ComparisonSlide
visual kinetic-canvas KineticCanvasSlide
visual kinetic-hero KineticHeroSlide
technical code-walkthrough CodeWalkthroughSlide
technical architecture-diagram ArchitectureDiagramSlide
technical terminal TerminalSlide

Typed slide classes expose named, typed slot fields — no raw slots dict required. Plain strings auto-coerce to TextBlock:

from decko_py import TitleSlide, HeaderBodySlide, ListBlock
from decko_py.models.rich_text import ListItem

DeckBuilder()
    .slide(TitleSlide(
        headline="My Deck",          # str → TextBlock automatically
        subtitle="Subtitle here",
        notes="Speaker notes here",  # shown in presenter mode
    ))
    .slide(HeaderBodySlide(
        title="Why Decko?",
        body=ListBlock(display="bullets", items=[
            ListItem(text="Fully typed"),
            ListItem(text="23 built-in templates"),
        ]),
    ))

DeckBuilder.slide() accepts both typed slide classes and raw Slide objects.

Inspect slot requirements at the REPL:

TitleSlide.slots_info()
# TitleSlide [title-slide]
#   headline             required   text  max_chars=120
#   subtitle             optional   text  max_chars=200
#   eyebrow              optional   text  max_chars=60
#   logo                 optional   media

TitleSlide.definition()  # returns the full BaseTemplate catalog entry

DeckBuilder.build() auto-validates content budgets by default. Pass strict=False to skip:

deck = builder.build()               # raises ValueError on budget violations
deck = builder.build(strict=False)   # skip validation

Extend BaseTemplate to define custom templates:

from decko_py import BaseTemplate, TemplateSlot, ContentBudget, AiHints

class SplitTemplate(BaseTemplate):
    id: str = "split"
    name: str = "Split Slide"
    category: str = "content"
    description: str = "Two-column layout."
    slots: list[TemplateSlot] = [
        TemplateSlot(id="left", accepts=["text", "list"], required=True,
                     content_budget=ContentBudget(max_chars=300)),
        TemplateSlot(id="right", accepts=["text", "media"], required=True,
                     content_budget=ContentBudget(max_chars=300)),
    ]
    layout_modes: list[str] = ["split"]
    ai_hints: AiHints = AiHints(
        when_to_use="Side-by-side comparison.",
        good_for=["comparisons", "text + image"],
        avoid=["charts", "tables"],
        suggested_follow_up=["header-body"],
    )

Validation

Register templates before validating. register_defaults loads all 23 built-ins:

from decko_py import validate_content, TemplateRegistry, register_defaults

reg = TemplateRegistry()
register_defaults(reg)

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

Metadata

Release files for decko-py 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for decko-py 0.2.1
File Size Uploaded Provenance Actions
decko_py-0.2.1.tar.gz 39.6 kB With provenance Details for decko_py-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for decko-py 0.2.1
File Interpreter ABI Platform Actions
decko_py-0.2.1-py3-none-any.whl Python 3 none any Details for decko_py-0.2.1-py3-none-any.whl

Total release size: 66.8 kB

Release files / decko_py-0.2.1.tar.gz

Download URL decko_py-0.2.1.tar.gz
Size 39.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f23e496b5f58aebd628e635f2f2e47e66384cab434d262a3014c6b7282f500dc
BLAKE2b-256 checksum
How to use checksums
57812c45d5a6dfbd8f7dced820c25a971de6b223fab0fa98fd8bfef88504f978
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 13, 2026.

Transparency log

Release files / decko_py-0.2.1-py3-none-any.whl

Download URL decko_py-0.2.1-py3-none-any.whl
Size 27.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4d49266cb685bfa081130740a6c72563dc9ff9a147b79db8280a7b32cf3f03ed
BLAKE2b-256 checksum
How to use checksums
b64cf168fb4fa5fc6372ade2d1ee7c9d3011783cfb2a5a7ea61d270bd3b479a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 13, 2026.

Transparency log

Security for decko-py 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for decko_py-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page