Skip to main content

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

Project description

pydantic-settings-export

PyPI version

Export your Pydantic settings to a 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

Usage

You can see the examples of usage 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.1.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

pydantic_settings_export-0.1.0-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pydantic_settings_export-0.1.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.12 Linux/6.5.0-1018-azure

File hashes

Hashes for pydantic_settings_export-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5f490755f8b4d55112336882a6417a4ff9f2f6f816d44200b42bf49ebc5bd91e
MD5 5bae6d9cdcb55c8bbf6e1dc44480decc
BLAKE2b-256 ebadae92f77e7398c375ae3a2a9cdf37a6fc4793e6be1e9670d893eb17055028

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for pydantic_settings_export-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 afb35888c719fb1c389596bfb04b919995194d014335028bdedc2849f00f13b7
MD5 28c8b2de63f2612c1add70fd48bbd42a
BLAKE2b-256 13d8511c1bf9dde64befc23352ecc66317784630f7a45d952645f69efe35393c

See more details on using hashes here.

Provenance

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