Metadata-Version: 2.4
Name: dalea
Version: 0.1.0
Summary: Python client for the Dalea wiki engine: typed pages, revisions, and backlinks.
Author: 
License: MIT
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# dalea

`dalea` is a Python client for the [Dalea](https://dalea.wiki) wiki engine. It
turns wiki pages into typed Python objects — pages, sections, backlinks, and
revision diffs — and gives you a small write surface for scripted edits. It is
useful for agents that read structured wikis, for CI jobs that reconcile links,
and for analysts who want to pull a wiki into a notebook.

## Features

- `Page`, `Section`, `Revision`, and `Backlink` models with `pydantic`.
- Read pages by slug or id; stream the page tree with a single iterator.
- Render page bodies to Markdown, HTML, or plain text via pluggable renderers.
- Compute and apply revision diffs; propose an edit as a pending revision.
- Backlink graph export to `networkx` for downstream analysis.
- Built-in retry and `requests.Session` reuse; thread-safe client instance.

## Installation

```bash
pip install dalea
# extras for rendering and graph export:
pip install "dalea[render,graph]"
```

## Quick start

```python
from dalea import DaleaClient

client = DaleaClient(base_url="https://dalea.wiki", token="ptn_...")

page = client.pages.get("python/asyncio")
print(page.title, len(page.sections))

for ref in client.backlinks("python/asyncio"):
    print(ref.source_slug, ref.context)

diff = client.revisions.diff(page.latest, page.revisions[-2])
print(diff.added_lines)
```

## API

- `DaleaClient.pages` — `.get(slug)`, `.list(prefix=)`, `.stream()`.
- `DaleaClient.revisions` — `.list(slug)`, `.diff(a, b)`, `.propose(slug, body)`.
- `DaleaClient.backlinks(slug)` — return `Backlink` objects with surrounding
  context spans.
- `dalea.render(page, to="markdown")` — render a `Page` to the target format.

## Configuration

`DaleaClient` accepts `base_url`, `token`, and `timeout`. The token can also be
read from `DALEA_TOKEN`, and the base URL from `DALEA_BASE_URL`.

## License

MIT
