Skip to content

```python exec="yes"

!/usr/bin/env python3

"""Script to generate credits from pyproject.toml dependencies."""

from future import annotations

import tomllib from pathlib import Path

ROOT = Path(file).resolve().parent.parent if "file" in globals() else Path.cwd()

def load_credits() -> str: """Load credits from pyproject.toml.""" pyproject = ROOT / "pyproject.toml" with pyproject.open("rb") as f: data = tomllib.load(f)

deps = data.get("dependency-groups", {}).get("dev", [])
lines = ["# Credits", "", "The following packages are used to generate this documentation:", ""]
for dep in deps:
    if isinstance(dep, str) and not dep.startswith(("-", "#")):
        pkg_name = dep.split("[")[0].split(">=")[0].strip()
        lines.append(f"- [{pkg_name}](https://pypi.org/project/{pkg_name}/)")

return "\n".join(lines)

if name == "main" or "file" not in globals(): print(load_credits())

```