Metadata-Version: 2.4
Name: gen-ssg
Version: 0.4.6
Summary: GenHTML, GenCSS, and GenSSG toolkit
Author-email: Flench04 <webmaster@flench.me>
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: lxml
Requires-Dist: markdown
Requires-Dist: python-dotenv
Requires-Dist: pyyaml

# Gen

Gen is a Python-first toolkit for building static websites.

It is split into two parts:

- `gen.html`: GenHTML, a small object model for creating, editing, parsing, and rendering HTML.
- `gen.ssg`: GenSSG, a static site build layer that discovers `.ghtml` page files, runs plugin hooks, builds GenHTML pages, and writes routes to `dist/`.

## Status

This is an early implementation. The core GenHTML tree model, parser, GenSSG dispatcher, CLI, and tests are in place.

## Install From Source

Create a virtual environment:

```bash
python3 -m venv .venv
source .venv/bin/activate
```

Install dependencies:

```bash
python3 -m pip install -r requirements.txt
```

Install this package locally:

```bash
python3 -m pip install -e .
```

Run tests:

```bash
PYTHONPATH=src python3 -m unittest discover -s tests
```

## CLI

Create a new GenSSG project:

```bash
gen init --dir my-site
```

Add a page:

```bash
gen add my-site/src/index.ghtml
```

Build the site:

```bash
gen build --dir my-site
```

Output is written to:

```text
my-site/dist/
```

## GenHTML Example

```python
from gen.html import Div, H1, P, Page, Text

page = Page()

with page:
    with Div(class_="content"):
        H1("Hello")
        P("Built with GenHTML")

print(page.render())
```

## GenSSG `.ghtml` Contract

A `.ghtml` file provides page context and build logic:

```python
from gen.html import Element, Page, Text


def CONTEXT(api):
    return {
        "route": "/",
        "title": "Home",
    }


def Build(api, context):
    page = Page()

    with page:
        with Element("body"):
            with Element("h1"):
                Text(context["title"])

    return page
```

`CONTEXT(api)` may return one dictionary or a list of dictionaries. Each dictionary is passed to `Build(api, context)`.

## Build A Distribution

From the repository root:

```bash
python3 -m build
```

This creates source and wheel distributions in:

```text
dist/
```
