Metadata-Version: 2.4
Name: pyd2lang-native
Version: 0.1.5
Summary: Python bindings to d2lang
Author-email: "Travis F. Collins" <travis.collins@analog.com>
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: D2_LICENSE.txt
Provides-Extra: sphinx
Requires-Dist: sphinx>=6; extra == "sphinx"
Provides-Extra: docs
Requires-Dist: sphinx; extra == "docs"
Requires-Dist: furo; extra == "docs"
Requires-Dist: sphinx-copybutton; extra == "docs"
Requires-Dist: pyd2lang-native[sphinx]; extra == "docs"
Provides-Extra: dev
Requires-Dist: nox; extra == "dev"
Requires-Dist: uv; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: ty; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Dynamic: license-file

<p align="center">
  <img src="docs/_static/logo.svg" alt="pyd2lang-native" width="400">
</p>

[![Build](https://github.com/tfcollins/pyd2lang-native/actions/workflows/build_wheels.yml/badge.svg)](https://github.com/tfcollins/pyd2lang-native/actions/workflows/build_wheels.yml)
[![Docs](https://github.com/tfcollins/pyd2lang-native/actions/workflows/docs.yml/badge.svg)](https://github.com/tfcollins/pyd2lang-native/actions/workflows/docs.yml)
[![PyPI](https://img.shields.io/pypi/v/pyd2lang-native)](https://pypi.org/project/pyd2lang-native/)
[![Python](https://img.shields.io/badge/python-%3E%3D3.10-blue)](https://pypi.org/project/pyd2lang-native/)
[![License](https://img.shields.io/github/license/tfcollins/pyd2lang-native)](https://github.com/tfcollins/pyd2lang-native/blob/main/LICENSE)

Native Python bindings for [d2lang](https://d2lang.com), the modern text-to-diagram language. Compile D2 diagram source code to SVG directly from Python — no CLI tools or subprocesses required.

Includes built-in **Analog Devices (ADI)** libraries for signal-chain shapes, software/AI architecture diagrams, pyadi-jif block diagrams, and ADI DataX overview diagrams, plus light and dark ADI-branded themes.

## Quick Start

```python
import d2

# Basic diagram
svg = d2.compile("x -> y -> z")

# ADI signal chain with branded theme
svg = d2.compile("""
  sensor: ADXL345 { class: sensor }
  amp: LT6230 { class: amplifier }
  adc: AD7606 { class: adc }
  dsp: ADSP-21489 { class: dsp-fpga }

  sensor -> amp -> adc -> dsp
""", adi=True)

# Dark theme variant
svg = d2.compile(code, adi=True, theme="dark")

# ADI DataX overview-style stack diagram
svg = d2.compile("""
  direction: down
  stack: ADI DataX Stack { class: datax-panel
    apps: Applications { class: datax-application }
    lib: libiio / pyadi-iio { class: datax-info }
    drivers: Linux IIO Drivers { class: datax-driver }
    hardware: ADI Hardware { class: datax-hardware }
    apps -> lib -> drivers -> hardware { class: datax-flow }
  }
""", library="datax")
```

## Installation

```bash
pip install pyd2lang-native
```

Pre-built wheels are available for Linux (x86_64, aarch64), macOS (Intel, Apple Silicon), and Windows.

## Documentation

Full documentation is available at the [project docs site](https://tfcollins.github.io/pyd2lang-native/).

## License

This project is licensed under the MPL-2.0 License. See the [LICENSE](https://github.com/tfcollins/pyd2lang-native/blob/main/LICENSE) file for details.

## Dependencies

The d2lang compiler is built as a native shared library (.so / .dll / .dylib) and bundled into platform-specific Python wheels.

- d2lang: [Project repo](https://github.com/analogdevicesinc/d2lang) and [License](https://github.com/tfcollins/pyd2lang-native/blob/main/D2_LICENSE.txt)
