Skip to main content

Export your Pydantic settings to a Markdown and .env.example files!

Project description

pydantic-settings-export

PyPI version Pepy Total Downloads

Export your Pydantic settings to Markdown and .env.example files!

This package provides a way to use pydantic (and pydantic-settings) models to generate a Markdown file with the settings and their descriptions, and a .env.example file with the settings and their default values.

Installation

pip install pydantic-settings-export
# or
pipx install pydantic-settings-export  # for a global installation and using as a CLI
# or
uv tool install pydantic-settings-export

Usage

You can see the usage examples of this package in the ./docs/Configuration.md and .env.example.

As code

from pydantic import BaseSettings
from pydantic_settings_export import Exporter, MarkdownSettings, Settings as PSESettings


class Settings(BaseSettings):
  my_setting: str = "default value"
  another_setting: int = 42


# Export the settings to a Markdown file `docs/Configuration.md` and `.env.example` file
Exporter(
  PSESettings(
    markdown=MarkdownSettings(
      save_dirs=["docs"],
    ),
  ),
).run_all(Settings)

As CLI

pydantic-settings-export --help

Configuration

You can add a pydantic_settings_export section to your pyproject.toml file to configure the exporter.

[tool.pydantic_settings_export]
project_dir = "."
default_settings = [
  "pydantic_settings_export.settings:Settings",
]
dotenv = { "name" = ".env.example" }

[tool.pydantic_settings_export.markdown]
name = "Configuration.md"
save_dirs = [
  "docs",
  "wiki",
]

Todo

  • Add tests
  • Add more configuration options
  • Add more output formats
    • TOML (and pyproject.toml)
    • JSON
    • YAML

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic_settings_export-0.3.3.tar.gz (28.9 kB view details)

Uploaded Source

Built Distribution

pydantic_settings_export-0.3.3-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_settings_export-0.3.3.tar.gz.

File metadata

File hashes

Hashes for pydantic_settings_export-0.3.3.tar.gz
Algorithm Hash digest
SHA256 62717b90b09965fe84a528e6595e4cf4423a87acc56a6dfb6fba181059f20c9c
MD5 e0e47d579499dedb5f4d13f068224b38
BLAKE2b-256 d2ef02bf11bae30320c002b67c4161599c7309177732de6eadf31c11de1a9cd9

See more details on using hashes here.

File details

Details for the file pydantic_settings_export-0.3.3-py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_settings_export-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 baf1f0ea32a41c3d5aafb80343e2f2c0ee4c2a58b1581a4595bafcc1e566a488
MD5 a9638a3a6b2e1561bc147108f882fc38
BLAKE2b-256 bf7b9b524a9daa949b8d84b26f0705ff1340f3aceb6a1121da10fcccc8c5ce01

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page