Metadata-Version: 2.3
Name: toml-tstring
Version: 0.2.2
Summary: TOML renderer for t-string structured data templates
Keywords: pep750,t-strings,toml,template-strings,structured-data
Author: Koudai Aono
Author-email: Koudai Aono <koxudaxi@gmail.com>
License: MIT
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: tstring-bindings>=0.2.2
Requires-Dist: tstring-core>=0.2.2
Maintainer: Koudai Aono
Maintainer-email: Koudai Aono <koxudaxi@gmail.com>
Requires-Python: >=3.14
Project-URL: Homepage, https://github.com/koxudaxi/tstring-structured-data
Project-URL: Repository, https://github.com/koxudaxi/tstring-structured-data
Project-URL: Documentation, https://github.com/koxudaxi/tstring-structured-data/blob/main/toml-tstring/README.md
Project-URL: Changelog, https://github.com/koxudaxi/tstring-structured-data/blob/main/CHANGELOG.md
Project-URL: Issues, https://github.com/koxudaxi/tstring-structured-data/issues
Description-Content-Type: text/markdown

# toml-tstring

TOML rendering for PEP 750 t-strings. Parsing and rendering happen in Rust;
this package is the Python wrapper.

Requires Python 3.14+.

This package depends on `tstring-bindings`, a native PyO3 extension. On
supported platforms, install from prebuilt wheels. Other environments require a
local Rust 1.94.0 toolchain build.

## API

```python
render_data(template, profile="1.1")  # -> Python data
render_text(template, profile="1.1")  # -> TOML text
render_result(template, profile="1.1")  # -> RenderResult (.text + .data)
```

Type alias: `TomlProfile = Literal["1.0", "1.1"]`

Parsed template structure is cached per process using `template.strings` +
profile as the key. Use `profile="1.0"` when you need the stricter TOML 1.0
behavior.

## How it works

The Python `Template` is converted to a Rust token stream and parsed into TOML
nodes -- assignments, key paths, headers, arrays, inline tables, literals, and
string families all become explicit nodes with interpolation preserved.
Rendering is driven by the parsed node type. The Rust `toml` crate handles
value materialization and normalization.

## Supported positions

- whole-value, key, dotted-key, table-header, and array-of-table interpolation
- string-fragment interpolation across all four TOML string types
- nested arrays, inline tables, and array-of-table sections
- integer forms (hex, binary, octal), special floats (`inf`, `nan`)
- `datetime`, `date`, and `time` values

## Limits

- `None` rejected (TOML has no null)
- offset `time` values rejected
- integers must fit signed 64-bit range
- values must be TOML-representable

## Verify

```bash
uv sync --group dev
uv run --group dev pytest
```

## See also

- [Project README](https://github.com/koxudaxi/tstring-structured-data#readme)
- [Backend support matrix](https://github.com/koxudaxi/tstring-structured-data/blob/main/docs/backend-support-matrix.md)
