Skip to main content

Cook your data into documents using Jinja2 templates

Project description

Kodudo

PyPI version Python versions License: GPL v3 Code style: ruff

Kodudo is a Bororo word for "to cook".

It is a minimal, functional Python tool that cooks your data into documents using Jinja2 templates. Designed to work seamlessly with aptoro, it separates data preparation from presentation, allowing you to transform validated data into HTML, Markdown, or any other text format.

Features

  • Data Agnostic: Works natively with Aptoro exports, plain JSON lists, or generic wrappers.
  • Jinja2 Powered: Leverage the full power of Jinja2 templates, inheritance, and macros.
  • Configuration over Code: Define complex rendering pipelines in simple YAML files.
  • Context Aware: Automatically injects metadata, configuration, and custom context into templates.
  • Multi-Output: Render multiple output files from a single config with outputs.
  • Per-Record Rendering: Generate one file per data record with foreach and path interpolation.
  • Multi-Format: Output to HTML, Markdown, text, or any text-based format.

Installation

pip install kodudo

CLI Usage

Kodudo provides a command-line interface for "cooking" documents from configuration files.

# Cook a single configuration file
kodudo cook config.yaml

# Cook multiple files at once
kodudo cook config1.yaml config2.yaml

# Use shell expansion
kodudo cook configs/*.yaml

Quick Start

import kodudo

# Cook using a config file (same as CLI)
paths = kodudo.cook("config.yaml")

# Cook with runtime overrides (no temp files needed)
batch = kodudo.load_config("config.yaml")
for locale in ("pt", "en"):
    kodudo.cook_from_config(
        batch.config,
        context={"lang": locale},
        output=f"docs/{locale}/page.html",
    )

# Render directly to a string
html = kodudo.render(
    data=[{"name": "Alice"}, {"name": "Bob"}],
    template="templates/users.html.j2",
    context={"title": "User List"},
)

Documentation

For full details on configuration options, template variables, and data formats, see the Documentation.

Configuration

Define your rendering process in a YAML configuration file:

# Single output
input: data/records.json
template: templates/page.html.j2
output: output/page.html
context:
  title: "My Documents"
# Multi-output (e.g., locales)
input: data/records.json
template: templates/page.html.j2
outputs:
  - output: en/page.html
    context: { lang: en }
  - output: pt/page.html
    context: { lang: pt }
# Per-record rendering
input: data/articles.json
template: templates/article.html.j2
output: articles/{article.slug}.html
foreach: article

Supported Formats

Input Data (JSON):

  • Aptoro Format: { "meta": {...}, "data": [...] }
  • Plain List: [ {...}, {...} ]
  • Generic Wrapper: { "results": [...] }

Output:

  • HTML
  • Markdown
  • Text
  • Any text-based format

License

GNU General Public License v3 (GPLv3)

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

kodudo-0.2.0.tar.gz (30.1 kB view details)

Uploaded Source

Built Distribution

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

kodudo-0.2.0-py3-none-any.whl (26.6 kB view details)

Uploaded Python 3

File details

Details for the file kodudo-0.2.0.tar.gz.

File metadata

  • Download URL: kodudo-0.2.0.tar.gz
  • Upload date:
  • Size: 30.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for kodudo-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4b9e11652d68de6e5b88d2f02281fc5eb457a38879019985f112087286c38949
MD5 54a6a2300e9a2d220e855bfa5dfeb7de
BLAKE2b-256 df125d7bda8e6d6c659f12f003a9cbb25b813f6856787ac9ed2ea87c10f38311

See more details on using hashes here.

File details

Details for the file kodudo-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: kodudo-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 26.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for kodudo-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7b5c9c6af1686a2f769e4a8ebe94b04c8dff2d515d03ade21ecbe4ec9994fad3
MD5 fd6bf5ba0eb8b619d4b6185be450f84c
BLAKE2b-256 d183ca3a3008cbdb14e875e5e670dc5c14ebe6a3986a64f7015574f082b0c8ec

See more details on using hashes here.

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